How to replace WordPress cron with real cron jobs

by

in

When it is working, don’t fix it!

If you do not use WPcron, just skip this post.
If WPcron works for you, don’t change to cron.

Only use cron if your WPcron does not serve you as needed.

Step one. Disable WPcron

Open the WordPress config file:

sudo nano wp-config.php

To disable the unreliable WordPress cron function add the following statement

define('DISABLE_WP_CRON', true);

 

Step 2. Activate cron in Ubuntu

Open cron

sudo crontab -e

Then insert the following statement for each WordPress site on your VPS. This example is what you could enter for three WordPress sites on your VPS:

0 */1 * * * wget -q -O - http://site1.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1
1 */1 * * * wget -q -O - http://site2.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1
1 */1 * * * wget -q -O - http://site3.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1

This command is set to run every hour. You can use whatever time you need. Cron requires resources and puts a load on your server. More often than every 15 minutes could be bad. Once every hour should be okay for most scheduling in WordPress.
If you have many WordPress websites, you should set them to run with 1 minute, 5 minutes or 10 minutes spacing to avoid slowing down the server.