Management Guides

WordPress Cron Not Working? Run WP-Cron From System Cron

Why WP-Cron misses scheduled posts and how to fix it on a VPS: disable the built-in trigger, run due events with WP-CLI from system cron, and clear the usual blockers.

When WordPress cron stops working, scheduled posts show "Missed schedule", backups and emails from plugins do not go out, and Site Health may report "A scheduled event has failed" or that the site could not complete a loopback request. The cause is nearly always the same: WP-Cron is not a real scheduler. It only runs when someone visits the site, and it starts its work by having the server request its own wp-cron.php over HTTP.

On a VPS the fix is to stop relying on visits. Set DISABLE_WP_CRON in wp-config.php and let the system's cron run wp cron event run --due-now every few minutes as the site's user. That works with no visitors, and it works when the loopback request is blocked.

The commands follow the WordPress developer handbook and the WP-CLI documentation; they were not run on a test server for this article.

What you see and where to look

What you seeLikely causeWhere to look
"Missed schedule" on a low-traffic siteNobody visited at the scheduled timeSystem cron, below
Nothing scheduled ever runsLoopback request blocked, or DISABLE_WP_CRON set with no system cronwp cron test, wp config get DISABLE_WP_CRON
Events are overdue, then all run at onceStuck doing_cron lock, or a task that runs for a long timewp transient get doing_cron
Cron worked until a move or domain changeWrong site URL, DNS or certificatewp option get siteurl
Site slow, thousands of events in the listA plugin keeps adding eventswp cron event list --format=count

How WP-Cron works

On each page load WordPress checks whether any scheduled event is due. If one is, it sends a non-blocking HTTP request from the server to https://your-site/wp-cron.php, and that second request runs the events. This has two consequences:

  • Low traffic: a post scheduled for 06:00 is published when the first visitor arrives after 06:00. If that is hours later, or the loopback request fails, it is late or missed.
  • High traffic: the check runs on every uncached request, and heavy tasks run on the same PHP workers that serve visitors. Behind a full-page cache PHP may not run for long stretches, and events are late for that reason.

See what is scheduled

WP-CLI shows the queue. Run it from the WordPress directory as the user that owns the site's files, not as root (see the WP-CLI guide):

cd /var/www/example.com
sudo -u www-data wp cron event list
sudo -u www-data wp cron schedule list
sudo -u www-data wp cron test

wp cron event list prints each hook with its next run time and recurrence. Events whose time has passed are overdue. wp cron test tries the loopback request and reports whether spawning works. To run one event by hand and see its errors:

sudo -u www-data wp cron event run wp_version_check

The fix: system cron and WP-CLI

1. Disable the visit trigger. Add this to wp-config.php above the "stop editing" line, or let WP-CLI do it:

sudo -u www-data wp config set DISABLE_WP_CRON true --raw
sudo -u www-data wp config get DISABLE_WP_CRON

The result in the file is define( 'DISABLE_WP_CRON', true );. Use sudo -u with whichever user may write the file if it is not the PHP user.

2. Add a cron job for the site's user. On Ubuntu and Debian that is usually www-data; on AlmaLinux and Rocky Linux it is the user of the PHP-FPM pool, often apache or nginx.

sudo crontab -u www-data -e
*/5 * * * * cd /var/www/example.com && /usr/local/bin/wp cron event run --due-now --quiet

Every five minutes suits most sites; use one minute if posts must go out to the minute. --due-now runs only events whose time has come, and it respects the doing_cron lock so runs do not overlap. Check the path with which wp. Running as the site's user matters: as root, files created by a task end up owned by root and WordPress cannot change them later (see WordPress file permissions).

Alternative: a systemd timer. It does the same job and keeps the output in the journal. Create two files:

# /etc/systemd/system/wp-cron-example.service
[Unit]
Description=Run due WP-Cron events for example.com

[Service]
Type=oneshot
User=www-data
WorkingDirectory=/var/www/example.com
ExecStart=/usr/local/bin/wp cron event run --due-now

# /etc/systemd/system/wp-cron-example.timer
[Unit]
Description=WP-Cron timer for example.com

[Timer]
OnCalendar=*:0/5
Persistent=true

[Install]
WantedBy=timers.target
sudo systemctl daemon-reload
sudo systemctl enable --now wp-cron-example.timer
systemctl list-timers wp-cron-example.timer

Without WP-CLI: request wp-cron.php. This is the method in the WordPress handbook. It still depends on HTTP reaching the site, so it does not help when loopback requests are the problem, and the task is subject to the web server's and PHP-FPM's timeouts.

*/5 * * * * wget -q --delete-after https://example.com/wp-cron.php

Confirm that it works

# the job ran (Ubuntu, Debian; the unit is crond on AlmaLinux, Rocky Linux)
sudo journalctl -u cron --since "15 min ago" | grep wp
# or, for the timer
sudo journalctl -u wp-cron-example.service --since "15 min ago"

# nothing is overdue any more
sudo -u www-data wp cron event list

Then schedule a test post a few minutes ahead and see that it is published on time without anyone opening the site. Note that wp cron test reports an error once DISABLE_WP_CRON is set; that is expected and only says the visit trigger is off.

Common causes when cron does not run

Loopback requests are blocked. The server must be able to reach its own public address. Test it from the server:

curl -s -o /dev/null -w '%{http_code}\n' https://example.com/wp-cron.php

Anything other than 200 explains the failure:

  • 401: HTTP basic auth protects the site, common on staging copies. Exclude wp-cron.php or use the WP-CLI method.
  • 403 or a challenge page: Cloudflare or another proxy, a security plugin, or an nginx rule that denies wp-cron.php blocks the server's own request.
  • Timeout: a firewall rule drops outgoing connections, or the server cannot route to its own public IP.
  • Certificate or DNS error: an expired certificate, or the name resolves to an old address. A redirect loop has the same effect; see too many redirects.

The WP-CLI cron job avoids all of these because it does not use HTTP.

Wrong site URL. WordPress sends the loopback request to the address in its settings. After a migration check that both values are the live address:

sudo -u www-data wp option get siteurl
sudo -u www-data wp option get home

A stuck lock. While cron runs, WordPress stores a doing_cron transient so that a second run does not start. The lock is honoured for 60 seconds by default (the constant WP_CRON_LOCK_TIMEOUT). If a task dies and events stay overdue, inspect and clear it:

sudo -u www-data wp transient get doing_cron
sudo -u www-data wp transient delete doing_cron

If one task regularly runs out of time or memory, find it by running the due events by hand and reading the output; the WordPress memory limit may need raising for the command line.

Thousands of events. A faulty plugin can add the same event on every page load. All events live in one autoloaded database option, so a huge list slows every request.

sudo -u www-data wp cron event list --format=count
sudo -u www-data wp cron event list --field=hook | sort | uniq -c | sort -rn | head

If one hook appears thousands of times, delete its events and then fix or remove the plugin, or they return:

sudo -u www-data wp cron event delete the_hook_name

ALTERNATE_WP_CRON

define( 'ALTERNATE_WP_CRON', true ); makes WordPress run cron inside the visitor's own request, using a redirect, instead of a loopback request. It exists for hosting where loopback requests cannot be made to work and no system cron is available. It still needs visitors. On a VPS you have system cron, so use that.

Multisite

In a multisite network each site has its own event queue. One command without --url only handles the main site. Loop over the sites in the cron job:

*/5 * * * * cd /var/www/example.com && for u in $(/usr/local/bin/wp site list --field=url); do /usr/local/bin/wp cron event run --due-now --quiet --url="$u"; done

Frequently asked questions

Is disabling WP-Cron safe?

Yes, as long as something else runs the events. DISABLE_WP_CRON only removes the trigger on page loads; the schedule itself stays.

Does this make the site faster?

It takes scheduled work off the requests that serve visitors. For other causes see Why is WordPress slow?.

Share story:

Continue reading other guides on How VPS.