WP Cron is a task scheduler used by WordPress and our plugins extensively. WP Cron runs when someone visits your site. In other words, if no one visits your site, WP Cron does not run. In that case, the tasks scheduled by our plugins will not be executed or will be delayed until the next WP Cron run.
To make sure the scheduled tasks are executed in a reliable and predictable way, we have two options:
Before using any of the options above. You need to disable WP Cron from running by adding the following code to your wp-config.php file:
You can use your operating system's task scheduler to trigger WP Cron at the specified intervals by following the steps below. Make sure to replace "Your_Site_URL" with your own domain URL.
There are multiple ways to schedule a task depending on your flavor of Windows. We've found that the easiest way to do it is the command line by using the schtasks command.
schtasks /create /tn "WordPress Cron Job" /tr "BROWSER_PATH http://Your_Site_URL/wp-cron.php" /sc TIME
Mac OS X/Linux
Each cron task must be created in a separate line per site. A cron task consists of five parts:
For example, to run WP Cron at minute 5 every hour:
5 * * * * /usr/bin/wget -q -O - http://example.com/wp-cron.php?doing_wp_cron
If wget is not installed, you can use curl. The following command runs every 5 minutes.
*/5 * * * /usr/bin/curl --silent "https://example.com/wp-cron.php?" > /dev/null 2>&1
Alternatively, you can use special strings to define the time part of your task:
Run once, at startup.
Run once a year
|0 0 1 1 *|
Run once a month
|0 0 1 * *|
Run once a week
|0 0 * * 0|
Run once a day
|0 0 * * *|
Run once an hour
|0 * * * *|
For example, to run WP Cron daily at midnight:
@daily wget -q -O - http://Your_Site_URL/wp-cron.php?doing_wp_cron
Please note that if you're using our plugins in multiple sites, you should create a task to run WP Cron for every site.
If using operating system level task scheduler is not an option for you. You can use one of the many webcron services to trigger your wp-cron.php at the specified intervals.