Disabling wp-cron.php in WordPress – Disable WordPress virtual cron

  • Post last modified:December 26, 2018
  • Post category:WordPress
  • Post comments:3 Comments
  • Reading time:2 mins read

WordPress uses a file called wp-cron.php as a virtual cron job. This is used to automate scheduled posting, checking updates for plugins and themes, email notification and other automated tasks.

Whenever a user access your blog, wp-cron.php is called automatically on each request. On a low traffic website, this is not a problem but if you have high traffic websites, this can result into high resource usage and it can also affect the website loading.

Disable default wp-cron.php behavior

It is possible to disable this virtual cron file (wp-cron.php). We can do it by adding necessary code in wp-config.php.

[1] Open your wp-config.php file.

[2] Add the following line in your wp-config.php file after your database details (after define(‘DB_COLLATE’, ”) line):

define('DISABLE_WP_CRON', 'true');

[3] Save your wp-config.php file.

Now WordPress should not call wp-cron.php file each time your blog is accessed by the visitor.

Setup manual cron job for wp-cron.php

Once you disable wp-cron.php using wp-config.php, WordPress will stop doing automated task. To overcome this problem, you can setup a manual cron job to execute wp-cron.php file. If your web hosting provider offers cPanel, you can setup a cron job as follow:

[1] Login to your cPanel.

[2] Form Advanced section, go to Cron jobs.

[3] Select Once an hour from the Common Settings drop-down.

[4] Now select Every 4 hours from the Hour drop-down.

[5] Add following line in Command and click on Add New Cron Job.

cd /home/YOUR_USER/public_html; php -q wp-cron.php

You will have to specify the correct path for your WordPress installation directory. Kindly adjust your command according to your WordPress installation path.

This Post Has 3 Comments

  1. Jane

    Thanks for the article.

    If anyone’s hosting doesn’t support Cron, or its Cron service is crap. You may try http://www.easycron.com.

Leave a Reply