WordPress logo

How to replace WordPress WP Cron with external cron

WordPress runs its scheduled work through WP-Cron: publishing scheduled posts, checking for updates, cleaning up old data, and the background jobs of plugins like WooCommerce. WP-Cron only wakes up when someone loads a page, so on a quiet site events run late, and on a heavily cached or locked-down site they may not run at all. To replace WordPress WP Cron with external cron, you turn off that page-load trigger with one line in wp-config.php and let a real scheduler run WordPress's due events every few minutes instead.

This guide covers all three ways to do it: a server crontab with WP-CLI, your hosting panel's cron jobs, and an online cron service for hosts with no cron at all. Everything was checked against the source code of WordPress 7.1.5 (the current release), WP-CLI 2.12 and Action Scheduler 4.2. The steps are the same on older WordPress versions.

Short answer

  1. Set up the external trigger first. Every 5 minutes, run wp cron event run --due-now from the server's crontab, or have your host's cron or an online cron service send a GET request to https://example.com/wp-cron.php.
  2. Add define( 'DISABLE_WP_CRON', true ); to wp-config.php, above the "stop editing" line.
  3. Check that nothing stays overdue, with wp cron event list or Tools → Site Health.

How WP-Cron works, and why it misses events

WP-Cron is not a background process. WordPress keeps a list of scheduled events in the database, each with the time it is due. On every request that loads WordPress, it checks whether an event is due. If one is and no other run is in progress, WordPress sends a quick, non-blocking request to its own /wp-cron.php and carries on. That second request is what runs the due events. Since WordPress 6.9, the check happens at the very end of the request, so it no longer holds up the page.

That design has four weak spots:

  • No visits, no events. An event due at 03:00 runs at the first page view after 03:00. On a quiet site that can be hours later, which is why scheduled posts end up marked "Missed schedule" in the post list.
  • Cached pages don't count. When a page cache or a CDN answers the request, WordPress never starts, so that visit doesn't check for events either. The better your caching, the fewer chances WP-Cron gets.
  • The loopback request can fail. The server has to reach its own address. HTTP authentication on a staging site, a firewall, a security plugin, or DNS that resolves differently inside the server can all stop it, and the events silently never run. Tools → Site Health tests this as "Your site can perform loopback requests".
  • Busy sites run the work in front of visitors. The events run in the same PHP workers that serve pages, at whatever moment traffic happens to trigger them.

An external cron fixes the first three: a scheduler calls WordPress on a timetable, whatever the traffic or caching. If you use WP-CLI, it fixes the fourth too, because the events then run outside the web server.

Diagram: by default a visitor's page load makes WordPress check for due events and send a loopback request to wp-cron.php, so events run late or not at all. With an external cron, a scheduler runs wp cron event run --due-now or requests wp-cron.php every 5 minutes, and events run on time at any traffic.
DISABLE_WP_CRON switches off the visitor path. wp-cron.php keeps working for the scheduled one.

Before you start

  • Check that your host hasn't done it already. Open wp-config.php and search for DISABLE_WP_CRON. Some managed WordPress hosts set it and run a server cron for you. If it's already there and set to true, ask your host how often their cron runs rather than adding a second trigger. Defining the constant twice also makes PHP warn that it's already defined.
  • Note your exact site address. Copy the WordPress Address (URL) from Settings → General, with the right https:// and with or without www. An HTTP trigger that lands on a redirect runs nothing.
  • Know what you run. If the site uses WooCommerce or another plugin built on Action Scheduler, plan for a trigger every minute (see below). Otherwise, every 5 minutes is the usual choice.
  • Do it in this order: trigger first, then the constant. wp-cron.php works whether WP-Cron is disabled or not (the file's own header says so), so the old and new triggers can run side by side for a few minutes. That way there is no window in which nothing runs your events.

Step 1: Set up the external trigger

There are two ways to run WordPress's due events from outside: run WP-CLI's cron command on the server, or request wp-cron.php over HTTP, exactly as WordPress does itself. Which one you can use depends on your hosting.

Decision chart: with SSH and WP-CLI, run wp cron event run --due-now from the server crontab. Without them but with cron jobs in cPanel or Plesk, request wp-cron.php with curl. With no cron at all, have an online cron service such as Cronit request wp-cron.php every 5 minutes.
Pick the first option your hosting allows.

Option A: server cron with WP-CLI

WP-CLI loads WordPress on the command line and runs every event that is due. Nothing goes over HTTP, so firewalls, page caches, HTTP authentication and web-server timeouts don't matter, and PHP has no execution time limit on the command line by default. If you have SSH access, this is the most dependable option.

First run it by hand, as the user that owns the WordPress files:

cd /var/www/example.com
wp cron event run --due-now

You get one line per event and a summary such as Success: Executed a total of 3 cron events. If nothing is due, it reports 0 events, which is fine. Now open that user's crontab (crontab -e while logged in as that user, or sudo crontab -u www-data -e) and add:

*/5 * * * * cd /var/www/example.com && /usr/local/bin/wp cron event run --due-now --quiet
  • Use full paths. Cron runs with a minimal PATH. Find WP-CLI's location with command -v wp, and check the finished line with our crontab checker.
  • --quiet hides the per-event lines, so cron only mails you when something goes wrong.
  • If cron reports env: php: No such file or directory, WP-CLI can't find PHP on cron's short PATH. Call PHP explicitly (/usr/bin/php /usr/local/bin/wp cron event run …) or add a PATH=/usr/local/bin:/usr/bin:/bin line at the top of the crontab.
  • Don't run it as root. WP-CLI refuses with "YIKES! It looks like you're running this as root" unless you add --allow-root, and files that root creates (caches, uploads) can't be changed by the site afterwards. Use the crontab of the user that owns the files.

One more detail: WP-CLI 2.12 doesn't check WordPress's cron lock, so if your events can run longer than the interval, a second run can start next to the first. On Linux, wrap the command in flock, which skips a run while the previous one still holds the lock file:

*/5 * * * * cd /var/www/example.com && flock -n /tmp/wp-cron-example.lock /usr/local/bin/wp cron event run --due-now --quiet

Option B: your host's cron requesting wp-cron.php

If you can add cron jobs but have no SSH or WP-CLI, which is typical for shared hosting, let the cron job request wp-cron.php. That is the same request WordPress sends itself, only now it no longer depends on visitors.

*/5 * * * * curl -fsS -o /dev/null https://example.com/wp-cron.php

If the server has no curl, use wget:

*/5 * * * * wget -q -O /dev/null https://example.com/wp-cron.php

With -fsS, curl stays silent when the call works and prints an error when the server answers with a 4xx or 5xx status, so cron only e-mails you about failures. wget's -q silences errors as well, so you won't hear about failures at all.

Four rules for the request, all straight from how wp-cron.php is written:

  • Use GET. wp-cron.php exits without doing anything when the request carries form data (a POST body).
  • Don't give doing_wp_cron a value. Many tutorials add ?doing_wp_cron to the URL. Without a value it's ignored. With one, such as ?doing_wp_cron=1, WordPress treats it as the key of a lock it never set and exits without running a single event.
  • Use the final address. curl doesn't follow redirects by default, so a request to http:// instead of https://, or without the www your site uses, stops at the redirect and runs nothing. A redirect isn't an error, so -f won't report it. Check with curl -I https://example.com/wp-cron.php: the status must be 200.
  • Expect an empty, fast response. On PHP-FPM and LiteSpeed servers, wp-cron.php sends its empty 200 response before it even loads WordPress, then runs the events. A 200 therefore means "the call arrived", not "every event succeeded". With Apache's mod_php, the connection stays open while the events run. If the caller gives up, the events still finish.

In cPanel: open Cron Jobs in the Advanced section. Choose a five-minute interval under Common Settings, or type */5 in the minute field and * in the others. Paste the curl or wget command, without the leading */5 * * * *, into Command, then click Add New Cron Job. cPanel e-mails each job's output to the Cron Email address; the quiet flags above keep that to failures.

In Plesk: go to Websites & Domains → Scheduled Tasks → Add Task, choose Fetch a URL, enter https://example.com/wp-cron.php and set it to run every 5 minutes. Run Now tests the task before you save it.

Some shared hosts don't allow cron jobs more often than every 15 minutes. That is enough for many blogs, but see how often to run it before you settle for it.

Option C: an online cron service

If your host offers no cron jobs at all, or you'd rather not maintain one on the server, an online cron service can request wp-cron.php for you. You also get something a crontab doesn't give you: a log of every call and an e-mail when the calls start failing. This is the setup in Cronit:

  1. Click New job.
  2. Give it a title such as WP-Cron – example.com. Leave the method at GET and enter https://example.com/wp-cron.php as the URL.
  3. Under Schedule, choose every 5 minutes (*/5 * * * *).
  4. If the site is behind a password prompt, as staging sites often are, fill in HTTP auth user and HTTP auth password.
  5. Under Notifications, keep When the job fails on and set Failures before notifying to 2 or 3, so a single network blip doesn't send you an e-mail.
  6. Click Send test request. You should get a 200 with an empty body. Then save the job.

Cronit's request timeout is at most 30 seconds. That is plenty here, because on most hosts wp-cron.php answers before it runs any events. Cronit doesn't follow redirects either, so a wrong address shows up as a failed run instead of silently doing nothing. Each call is listed with its status code and duration and kept for 30 days. As with any HTTP trigger, that history tells you WordPress was called on time, not that each event inside succeeded. Our guide to monitoring cron jobs covers checking the work itself.

Each call counts as one run of your plan's monthly allowance. Every 5 minutes is about 8,640 runs in a 30-day month, and every 15 minutes about 2,880. Compare that with the plans under pricing.

Step 2: Turn off the built-in trigger

Once the external trigger works, stop WordPress from triggering itself on page loads. Open wp-config.php in the WordPress root folder (WordPress also finds it one folder above) and add this line above the comment /* That's all, stop editing! Happy publishing. */:

define( 'DISABLE_WP_CRON', true );

With WP-CLI, you can do the same without opening the file. --raw writes true as a PHP value rather than the string 'true':

wp config set DISABLE_WP_CRON true --raw

What the constant changes, and what it doesn't:

  • Page loads stop checking for due events and stop sending the loopback request. That is all it does.
  • Your scheduled events stay where they are, and plugins keep scheduling new ones.
  • wp-cron.php keeps working when something requests it, and so does wp cron event run. Your external trigger relies on exactly that.

Watch out

Don't confuse it with ALTERNATE_WP_CRON. That constant only changes how a visitor's page load starts WP-Cron, using a redirect instead of a loopback request. It is still driven by visitors, and once DISABLE_WP_CRON is set, it has no effect at all.

Step 3: Check that events run

Give the new trigger two or three intervals, then check the result in one of these ways.

List the events with WP-CLI

wp cron event list --fields=hook,next_run_relative,recurrence

Overdue events show now in the next_run_relative column. A few of those between two runs of your trigger is normal. If the same events still say now after a full interval, nothing is running them.

Look at Site Health

Open Tools → Site Health. WordPress knows that a site with DISABLE_WP_CRON runs its events on an outside schedule and allows more slack. It reports "A scheduled event is late" once an event is more than 15 minutes overdue, and "A scheduled event has failed" after an hour. Without the constant, it calls any overdue event late and treats 5 minutes as failed. So run the external cron more often than every 15 minutes if you want Site Health to stay quiet.

Ignore what wp cron test says

wp cron test checks WordPress's own page-load mechanism. With DISABLE_WP_CRON set, it always fails with "The DISABLE_WP_CRON constant is set to true. WP-Cron spawning is disabled." That is expected and doesn't mean your external cron is broken.

Run a real test

Schedule a draft post 10 minutes ahead. It should be published within one trigger interval of that time. If you'd rather see the events in wp-admin, the WP Crontrol plugin lists every event with its next run and flags events that missed their schedule.

How often should the external cron run?

An event can wait up to one interval after it's due, so pick the interval from the most frequent event you rely on and how late it's allowed to run.

IntervalCron expressionGood forCalls per 30-day month
Every minute* * * * *WooCommerce stores and other sites that use Action Scheduler; anything that must run within a minuteabout 43,200
Every 5 minutes*/5 * * * *Most sites: scheduled posts, plugin e-mails, backups, update checksabout 8,640
Every 10 minutes*/10 * * * *Blogs and brochure sites where a few minutes don't matterabout 4,320
Every 15 minutes*/15 * * * *Only if your host allows nothing more frequent; Site Health may flag late eventsabout 2,880

Calling often costs little. If nothing is due, wp-cron.php exits as soon as WordPress has loaded, and wp cron event run --due-now runs nothing. Need a different timetable? Build one with the crontab generator.

WooCommerce and Action Scheduler

WooCommerce, and many plugins built on the same library, queue background work in Action Scheduler: webhook deliveries, Analytics data imports and, with WooCommerce Subscriptions, renewal payments. Action Scheduler has no clock of its own. Its queue runner is a WP-Cron event, action_scheduler_run_queue, that repeats every minute. Each run works through batches of 25 actions for up to about 30 seconds. While someone is working in wp-admin, Action Scheduler also starts an extra runner, at most once a minute.

So once WP-Cron is disabled, the queue moves at the pace of your external cron. With a 5-minute trigger, a queued action can wait up to 5 minutes. For a store, either run the trigger every minute or give Action Scheduler its own server cron entry. The WP-CLI runner isn't limited to 30 seconds and keeps going until no due actions are left, which also clears big backlogs faster:

* * * * * cd /var/www/example.com && /usr/local/bin/wp action-scheduler run --quiet

To check the queue, open WooCommerce → Status → Scheduled Actions (Tools → Scheduled Actions on sites without WooCommerce). The Pending list should not hold actions whose scheduled date is well in the past.

Multisite networks

Each site in a network keeps its own list of events, so each needs its own trigger. DISABLE_WP_CRON in wp-config.php applies to the whole network.

With WP-CLI, loop over the sites in a small script, for example /usr/local/bin/wp-cron-network.sh:

#!/bin/sh
PATH=/usr/local/bin:/usr/bin:/bin
cd /var/www/example.com || exit 1
for url in $(wp site list --field=url); do
  wp cron event run --due-now --url="$url" --quiet
done

Make it executable with chmod +x and schedule it like the single-site command:

*/5 * * * * flock -n /tmp/wp-cron-network.lock /usr/local/bin/wp-cron-network.sh

Newer WP-CLI builds add a --network flag to wp cron event run that does this loop for you. It isn't in the stable 2.12 release yet.

Over HTTP, create one job per site, each requesting that site's own address: https://example.com/wp-cron.php, https://shop.example.com/wp-cron.php, or https://example.com/blog/wp-cron.php for a site in a subdirectory.

Troubleshooting

SymptomLikely causeFix
The trigger gets 403 ForbiddenA security plugin, web application firewall or bot protection blocks wp-cron.php or the callerAllow requests to /wp-cron.php from your trigger, or switch to WP-CLI, which doesn't use HTTP
The trigger gets 401 UnauthorizedThe site is behind HTTP authenticationSend the credentials: curl -u user:password …, or the HTTP auth fields in Cronit
The trigger gets 301 or 302Wrong address: http vs https, or wwwUse the exact WordPress Address from Settings → General
The trigger gets 200, but events stay overdueThe URL has a doing_wp_cron value, the request is a POST with a body, or it reaches another copy of the site (old server, staging)Send a plain GET to /wp-cron.php, and check that the domain resolves to this server
The command works by hand but not from cronDifferent user, a shorter PATH, or a different PHP versionUse full paths and the site user's crontab; see our cron troubleshooting checklist
Cron e-mails you every few minutesThe command's normal output isn't silencedAdd --quiet to WP-CLI, or -fsS -o /dev/null to curl
Site Health says "A scheduled event is late"The trigger runs every 15 minutes or less often, or has stoppedRun it every 5 or 10 minutes, and check the trigger's own log
Long events overlapA run takes longer than the intervalWrap the cron command in flock -n, or move the heavy work to WP-CLI

Should you block public access to wp-cron.php?

Anyone can request wp-cron.php, with or without DISABLE_WP_CRON. That is less dramatic than it sounds: a call only runs events that are already due, and WordPress's lock stops a second run from starting while a recent one is still going. Each call costs about as much as an uncached page view.

If you use WP-CLI, nothing needs wp-cron.php over HTTP any more, and you can close it. In nginx, inside the site's server block:

location = /wp-cron.php {
    deny all;
}

In Apache 2.4, in .htaccess:

<Files "wp-cron.php">
    Require all denied
</Files>

If your trigger requests wp-cron.php over HTTP, keep it open. Blocking it then stops every scheduled event on the site.

FAQ

Does DISABLE_WP_CRON stop scheduled posts from publishing?
Yes, if nothing else runs WP-Cron. The constant only turns off the page-load trigger, so scheduled posts, update checks and plugin events wait until something requests wp-cron.php or runs wp cron event run. Set up the external trigger first, then add the constant.
How often should an external cron call wp-cron.php?
Every 5 minutes suits most sites. Use every minute for WooCommerce stores and other sites that rely on Action Scheduler. Run it more often than every 15 minutes, because Site Health reports an event as late once it is more than 15 minutes overdue.
Should I use WP-CLI or request wp-cron.php?
Use WP-CLI when you have SSH access: it runs outside the web server, so caches, firewalls, HTTP authentication and web timeouts don't apply. Requesting wp-cron.php over HTTP works on any host and is what WordPress does itself, so use it when you only have a control panel cron or no cron at all.
Can I run php wp-cron.php from cron instead?
It often works on a single site, but wp-cron.php is written for web requests. On the command line there is no host name or request URL, which some plugins read, and on multisite WordPress picks the site from the host name. WP-CLI sets up the environment and takes --url, so prefer it.
Does disabling WP-Cron make WordPress faster?
A little. Page loads stop checking for due events and stop sending the loopback request, though since WordPress 6.9 that already happens at the end of the request. The bigger gain is predictability: with WP-CLI, heavy events no longer run in the PHP workers that serve visitors.
Is ALTERNATE_WP_CRON an alternative to an external cron?
No. ALTERNATE_WP_CRON only changes how a visitor's page load starts WP-Cron, using a redirect instead of a loopback request. It is still driven by visitors, and once DISABLE_WP_CRON is set it has no effect.
How do I undo the change?
Delete the DISABLE_WP_CRON line from wp-config.php, or set it to false, and remove the cron job. WordPress goes back to checking for due events on page loads straight away.

Run online cronjobs without server setup

Plan, schedule and run periodic tasks and scripts, from your browser with the first online cronjob platform.

Try for free