wp-cron.php is a script that performs periodic maintenance tasks that WordPress needs to do. This includes:

Posting scheduled posts;
Emailing notifications of new comments or other events;
Running plugins such as Akismet to filter comments for spam

This script runs by default every time that a new visitor loads a page on your site, as such if you have 100 viewers viewing your site at the same time it would mean that you have 100 processes of wp-cron.php running and consuming memory and cpu resources, this can result in your site consuming too much resources which will have other consequences in the smooth operation of your site.

How to stop wp-cron.php consuming resources

It is recommended on large sites to disable WordPress from running wp-cron.php every time a viewer visits a page of your site. This is quite easy to do, you need to locate your wp-config.php file and add the following at the bottom:

define('DISABLE_WP_CRON', true);

The next step is to setup the script to run using a cron job at a regular interval. Once you have decided how often to run your job, the command to enter will be:

/usr/bin/wget -O /dev/null http://www.mydomain.com/wp-cron.php?doing_wp_cron

Replace "mydomain.com" above with your own website address.

How often should wp-cron.php run?

This would depend on how frequently you update your site however we would recommend running wp-cron.php at least every 24 hours, if you are constantly updating your site we wouldn't recommend running wp-cron.php more than every 30 minutes.

If you do find that you are getting a lot of spam comments and Akismet is not able to cope with this then you can set the wp-cron.php to run more frequently.



Did you find this article useful?