Cronjobs can be used to schedule tasks at fixed times, dates or intervals on your WordPress Web site. A WordPress cronjob could be used to schedule a post, check for updates, or run a backup plugin on a predefined time.
WP-Cron is used to simulate a cronjob in WordPress. The amount of traffic to your site can have an impact on page load times. Today we’ll show you how to disable WP-Cron, and instead, use a remote cronjob for faster performance.
WP-Cron Performance Issues
We’ve had a lot of issues with WP-Cron, the WordPress built-in cron handler. WP-Cron doesn’t actually perform a cronjob. It’s just what WordPress created to imitate a system cronjob.
WP-Cron doesn’t run continuously. The default setting of wpcron.php is to fire on each page load. This can be problematic for sites with high traffic. WordPress will sometimes send a request to WordPress for PHP workers. If the site doesn’t have enough PHP workers, WordPress will create the cronjob, however the worker must wait and the cronjob just sits there.
It’s also possible to reverse the situation. Schedules can be overlooked if a site isn’t getting a lot traffic. This could happen because no one has loaded a page.
It’s better to disable WP-Cron and instead use system cronjobs. This is recommended by the official Plugin Handbook and runs according to a pre-defined schedule.
How to Disable WP-Cron
Add the following code to disable WP-Cron in your wp-config.php file. This will be just before the line “That’s all, stop editing! Happy blogging.” Note: This prevents it running on page loads, but not when it is called directly via wp-cron.php though.
Schedule Cronjob with Remote Provider
You can use EasyCron to set-up external cronjobs on your server, if you aren’t comfortable with crontab or SSH, or your hosting provider doesn’t provide appropriate access to you. EasyCron is our recommended solution, next to real cronjobs via crontab on your server. While we use real cronjobs via crontab on our server, we’ve previously used EasyCron ourselves without issue.
Just set-up a cronjob at EasyCron with the “URL to call” pointing to wp-cron.php within your WordPress installation. For example: https://your-wordpress-domain.com/wp-cron.php?doing_wp_cron