Replace WP-Cron with a scheduled task

wordpress, wp-cron, disable_wp_cron, scheduled posts, cron, woocommerce, schedules · 0 found this helpful

WordPress has its own task runner, WP-Cron. It publishes scheduled posts, sends emails from plugins, and runs shop tasks. WP-Cron only runs when someone visits the site, so on a quiet site tasks run late, and on a busy site they add work to page views. Schedules can run the same tasks every minute instead.

What the switch does

  • Adds a task called WordPress tasks for your site, which runs WordPress's tasks every minute. If a run is still going when the next one is due, the next one is skipped.
  • Adds this line to the site's wp-config.php, so WordPress stops running tasks on page views:
define( 'DISABLE_WP_CRON', true ); // Added by Barbrick: a cron job runs WordPress tasks
  • Keeps a copy of wp-config.php before the change, and checks that the site still loads afterwards. If it doesn't, we put the file back as it was.

Turn it on

  1. Open Account → Hosting → your site → Schedules.
  2. Click WordPress tasks. If you have no schedules yet, click Replace WP-Cron instead.
  3. Turn on the switch next to the site. Each WordPress site in your account has its own switch.
The WordPress tasks drawer with a switch for each WordPress site

The site's line changes to Runs every minute from Schedules, and the first run happens within a minute.

Turn it off

Turn off the site's switch. We delete the task and remove our line from wp-config.php, so WordPress runs its tasks on page views again. Your site never goes without a task runner.

If wp-config.php already turns off WP-Cron

If wp-config.php already has define( 'DISABLE_WP_CRON', true );, we leave it alone and only add the task. Turning the switch off then leaves your line in place, so WordPress tasks stop running until you remove that line yourself.

If the file sets DISABLE_WP_CRON to something other than true, the task is still added, and a message asks you to change that line to true or remove it.

If something goes wrong

Problem Fix
"We couldn't find where to add the setting" wp-config.php doesn't have the usual "stop editing" line. Add the define line above require_once ABSPATH . 'wp-settings.php'; yourself. The task runs either way
Scheduled posts still publish late Open the task's History. If runs fail, the output says why. A plugin error shows there too. See See past runs and their output
Runs fail with "Allowed memory size" A plugin's task needs more memory. Raise memory_limit for the site, or ask the plugin's author
A plugin says WP-Cron is off That's expected. The plugin's tasks still run, from Schedules

For one-off task runs or to list scheduled events, see Use WP-CLI.

Was this helpful?

Still stuck? Ask us and we'll walk you through it.