CRON jobs are used to schedule tasks at periodic fixed times, dates, or intervals on your WordPress site. Some examples of a WordPress cron job might involve scheduling a post to publish, checking for updates, or a backup plugin running on a predefined schedule.

In WordPress, this is handled by WP-Cron, which is used to simulate a system cron. However, depending on the amount of traffic to your site, using the built-in cron handler can actually start to impact your page load times. So today we’ll show you how to disable WP-Cron (wp-cron.php) and instead use a system cron for faster performance.

Performance Issues with WP-Cron

We deal with a lot of high-traffic and demanding sites at Kinsta. Because of this, we’ve seen a lot of performance issues with the WordPress built-in Cron handler: WP-Cron. First off, it’s important to understand that WP-Cron is not a real cron job, it’s simply what WordPress has created to mimic what a system cron does.

WP-Cron does not run continuously. By default, the wp-cron.php fires on every page load, which on high-traffic sites can cause problems. If a site doesn’t have enough PHP workers, sometimes a request will come in, WordPress will spawn the cron, but the cron has to wait for the worker, and therefore just sits there.

The reverse scenario is also true. If a site doesn’t have a lot of traffic, schedules could be missed due to the fact that no one has loaded a page.

A better approach is to disable WP-Cron and use the system cron instead. This runs on a pre-defined schedule and is even recommended in the official Plugin handbook.

WordPress

UserAgent: WordPress/5.9.3; https://smied.net

How to Disable WordPress Cron

Via wp-config.php

Simply paste the following code in your wp-config.php file before the line that says “That’s all, stop editing! Happy blogging.”:

Warning:
This disables it from running on page load, not when you call it directly via wp-cron.php.
define('DISABLE_WP_CRON', true);
Info:
Add Cron – “crontab -e”
List of crons – “crontab -l”
Where file stored? – “cat /var/spool/cron/crontabs/root”
Сron logs – “grep CRON /var/log/syslog”

Wget

Install Wget

sudo apt-get install -y wget

Cron

* * * * * wget --quiet -O - https://smied.net/wp-cron.php?doing_wp_cron > /dev/null 2>&1

Curl

Install Curl

sudo apt-get install -y curl

Cron

* * * * * curl --insecure --silent https://smied.net/wp-cron.php?doing_wp_cron > /dev/null 2>&1

PHP

Install PHP

Help – https://www.php.net/manual/en/features.commandline.options.php

sudo apt-get install -y php-fpm or sudo apt-get install -y php7.2-cli

Cron

* * * * * php -q -f /var/lib/docker/volumes/Hestia-home/_data/hosting/web/smied.net/public_html/wp-cron.php > /dev/null 2>&1


If you have found a spelling error, please, notify us by selecting that text and pressing Ctrl+Enter.

Scroll up

Spelling error report

The following text will be sent to our editors: