WordPress - How to reduce WP-Cron resource usage

WordPress includes a WP-Cron.php file that carries out a list of maintenance tasks on your website to keep things running smoothly.

As its name suggests, WP-Cron should be setup to run as a cron job on your hosting account. When this hasn't been done, WordPress will run the script every single time someone visits your website, which can really use up a lot of CPU (computing power) and EP (entry processes) on your web hosting plan!

Thankfully, it's easy enough to fix this by disabling WP-Cron and then configuring a cron job for it to run a little less frequently!

Step 1 - Add a line to the wp-config.php file.

Open the wp-config.php file located in the main directory of your WordPress website and add a new line of code:

define('DISABLE_WP_CRON', true);

This line should be added under the first define in the file.

Step 2 - Create a new cron job in your cPanel control panel

Log into your cPanel control panel and navigate to Advanced => Cron Jobs

You'll see a list of any existing cron jobs and the option to create a new cron job.

For most websites we recommend creating a cron job to run twice a day. For busy websites the cron job should run more frequently, once an hour, or up to once every 15 minutes for very busy websites.

Here is an example of a cron job command that we recommend:

wget -O /dev/null https://exampledomain.com/wp-cron.php?doing_wp_cron > /dev/null 2>&1

You should paste this command into the form to create a new cron job, but change exampledomain.com to your actual domain name!

If you encounter issues with the above cron job, here is an alternative command that will achieve the same thing:

cd /home/example-username/public_html; php -q wp-cron.php

You should paste this into the form to create a new cron job, but change exampledomain.com to your actual domain name!

Step 3 - If you use iThemes Security plugin.

Some security plugins block requests to your website using the wget command. In particular iThemes Security adds lots of code to the .htaccess file to block different requests. Please open the .htaccess file in the main directory of your website and look for a line:

RewriteCond %{HTTP_USER_AGENT} ^Wget [NC,OR]

If that line exists please remove it and save the file.


That's it all done!

If you're familiar with the "Resource Usage" page in your cPanel control panel, you should notice going forward there are a lot less requests for wp-cron.php and therefore less CPU and EP usage.

Was this answer helpful?