7 April 2022

The default WordPress cron can be a bit of a resource hog. The script itself is useful; among others it checks if there are WordPress updates and if there are any scheduled posts that should be published. However, the wp-cron.php script runs on every page load. That is waste of resources, and it can slow down your website.

Replacing the WordPress cron via Toolkit

You can easily replace the WordPress cron with a real cron job. If you have access to WordPress Toolkit then you can simply toggle Take over wp-cron.php to on.

WordPress Toolkit lets you replace the default WordPress cron with a real cron job by just flicking a switch. The image shows the toggle's help text, which explains why replacing the default WordPress cron is useful.
Image: replacing the default WordPress cron.

Managing the replacement cron

The Take over wp-cron.php option does two things. Firstly, it disables the default WordPress cron by adding this rule to your website’s wp-config.php file:

define ('DISABLE_WP_CRON', true);

Secondly, it adds a proper cron job that runs twice an hour. The exact times at which the cron job runs is picked randomly. In my case the cron job runs at 12 and 42 minutes past the hour:

12,42 * * * * cd /home/example/public_html && /usr/local/bin/php /home/example/public_html/wp-cron.php

You can at any time enable the default WordPress cron again via Toolkit. If you want you can also change how often the cron job runs via cPanel’s cron jobs page.

Manually replacing the WordPress cron

As shown above, replacing the default WordPress cron with a proper cron is a two-step process: you need to disable the default cron by adding a rule to the wp-config.php file and then set up a “proper” cron job. The article about cron jobs in cPanel walks you through how to do that step-by-step.

Other tips

This article is part of a series about things you can do to optimise your WordPress website and make it more secure. The other articles cover the following topics: