Guide to to Disable the wp-cron.php in WordPress

Category : WordPress

A Cron Job is basically a scheduled task and the wp-cron.php file is a way to check that list of task and run them if their time has passed. But this file can not self-execute so WordPress has to access it every single time someone visits your site to see if there is anything on the list that needs to be done. That can be demanding, especially when you start to get traffic across multiple websites on one hosting account. Things like scheduled database backups, checking for plugin updates, clearing the cache, publishing a scheduled post and more. If you have a lot of these running rampant every 15 minutes or hour they start to stack on top of each other.

So we want to stop this insanity that runs every time someone visits our page.  So here is how we do it.

Requirements

  • FTP, SFTP or File Manager write access to WordPress Site.
  • cPanel Login Credentials.

Procedure

  1. Login to your cPanel account where your WordPress is Hosted
  2. Open File Manager
  3. Locate file wp-config.php inside home directory of your WordPress site and edit.
    edit wp-config.php
  4. Locate define(‘DB_COLLATE’, ”); line inside wp-config.php file and just below that line write the following flag.

    /** Disable WordPress Cron
    define(‘DISABLE_WP_CRON’, true);

    add disable flag

  5. Save and Exit.
  6. Goto Homepage of cPanel and Locate CronJobs feature and open it.
    cron jobs
  7. Go to Add a New Cron Job, select Common Settings and select option Once Per Hour
  8. At the Command Field type the below command to run wp-cron.php once per hour
    cd /home/your_username/public_html; php -q wp-cron.php
    Note – Here your_username should be replaced with your cPanel Username and this command will run automatically after one hour cycle.
    add new cron
  9. Tap on button Add New Cron Job
  10. It will show message Cron Job successfully Added