How to Run WordPress Cron Properly on a VPS Instead of Fake Visits
WordPress cron on a VPS works best when a real system cron job triggers it, not when you hope a visitor shows up at the right minute. Out of the box, WordPress runs scheduled tasks only when someone loads a page. On a VPS you own the scheduler, so there is no reason to leave publishing, backups, and cleanup jobs at the mercy of traffic.
This guide walks through the whole switch: why visit-triggered cron fails, how to turn it off, how to set up a system cron job that calls WP-CLI, and how to debug events that still refuse to run. Every command assumes a typical Ubuntu VPS with Nginx, PHP-FPM, and WP-CLI installed.
Why WordPress Cron Depends on Visits
WordPress has no background daemon. Every page load checks a list of scheduled events and runs any that are due. The file wp-cron.php handles this check. When traffic is steady, the system mostly works. When traffic is thin, tasks slip.
Picture a small site that gets its last visit at 9 pm. A post scheduled for 10 pm will sit unpublished until the first visitor arrives the next morning. A daily backup set for 3 am runs at 8 am instead, or not at all if a caching plugin serves the first visitor a static page.
The failure mode is silent: nothing errors out, nothing logs a warning, and the dashboard shows the event as scheduled. You only notice when a scheduled post appears hours late. For a store or membership site, that delay is a real problem. That is why wordpress scheduled tasks deserve a real scheduler instead of piggybacking on traffic.
WordPress Cron on a VPS vs wp-cron: What Actually Changes
A system cron job runs on a clock, whether or not anyone visits your site. You tell the server “run this command every five minutes” and it does, at 3 am on a Sunday just as reliably as at noon on a weekday. That is the whole difference, and it is the only difference that matters.
| Behaviour | wp-cron on visits | System cron + WP-CLI |
|---|---|---|
| Trigger | A page load | The server clock |
| Runs at 3 am with no traffic | No | Yes |
| Affected by page caching | Yes, cached hits can skip it | No |
| Timing accuracy | Minutes to hours late | Within a minute |
| Needs a web request | Yes | No |
The switch has two parts. First you stop WordPress from checking cron on every visit. Then you add a system cron job that runs the same checks on a fixed schedule. Nothing about your plugins or scheduled events changes. The same events run, just on time. The same pattern applies to other server jobs: a MySQL backup script driven by cron runs on the clock because the server should not wait for a visitor before doing maintenance work.
Step 1: Disable wp-cron in wp-config.php
Open wp-config.php in your WordPress root and add this line above the comment that says “That’s all, stop editing!”:
define( 'DISABLE_WP_CRON', true );
Save the file and load any page once to confirm nothing breaks. Scheduled events will no longer fire on visits, which is expected: nothing triggers them yet, and step 2 fixes that.
Two warnings. First, do not set this constant and then forget the cron job: a site with wp-cron disabled and no replacement scheduler will never run scheduled tasks at all. Second, some hosts and performance plugins re-enable wp-cron through their own settings, so check for a cron override if events still fire on visits.
Step 2: Add a Real System Cron Job
Open the crontab for the user that owns the WordPress files, usually www-data:
sudo crontab -u www-data -e
Add a line that calls wp-cron.php every five minutes:
*/5 * * * * curl -s https://example.com/wp-cron.php?doing_wp_cron > /dev/null 2>&1
Replace example.com with your own domain. The doing_wp_cron parameter tells WordPress this is a cron run, and the redirect to /dev/null keeps the output out of your mailbox. This method works, but it still goes through Nginx, PHP-FPM, and any caching layer in front of them. The better option is to skip HTTP entirely and run WP-CLI directly, which is step 3.
Step 3: Run Events with WP-CLI Instead
WP-CLI can run due cron events from the command line without a web request. The wp-cli cron event run command is the workhorse here. A cron entry like this checks for due events every five minutes:
*/5 * * * * cd /var/www/example.com && /usr/local/bin/wp cron event run --due-only --path=/var/www/example.com >> /var/log/wp-cron.log 2>&1
Adjust the paths to match your server. /var/www/example.com is your WordPress root, and /usr/local/bin/wp is where WP-CLI lives on most installs; run which wp if you are not sure. The --due-only flag limits the run to events whose time has come, so the job finishes fast.
One detail catches people out: the cron job must run as the same user that owns the WordPress files. Running it as root creates root-owned log files that PHP-FPM running as www-data may fail to write to. If you used sudo crontab -u www-data -e, you are already set.
Systemd timers are a solid alternative: a timer fires on a schedule and runs the same WP-CLI command. See our guide to running scheduled tasks with systemd timers instead of cron for the unit files.
Picking Schedules That Fit Your Site
Every five minutes is the right interval for most sites. Most built-in WordPress events run hourly, twice daily, or daily, so a five-minute check catches each one within five minutes of its due time. Running the check every minute adds load for no benefit unless a plugin schedules events more often than that.
Some events deserve their own timing. A daily database backup at 2 am should run as its own cron entry, not as a WordPress event, because a backup needs to happen even if WordPress itself is broken. The same logic applies to the daily WordPress database backup script many VPS owners already run: keep backups in system cron and content tasks in wp-cron, so each layer stays independent.
Watch out for plugins that register aggressive schedules. A stats plugin that schedules a job every minute can turn a five-minute WP-CLI run into a long one. List what is actually scheduled with:
sudo -u www-data /usr/local/bin/wp cron event list --path=/var/www/example.com
Look at the next_run column. Events with a next run far in the past are stuck, and events that repeat every minute from a plugin you barely use are worth disabling.
Debugging Missed Events and Logging
When a scheduled post still does not publish, check three things in order: the system cron job, the WP-CLI command, and the event list.
First, check whether the cron job ran at all by reading the log file from step 3:
tail -n 50 /var/log/wp-cron.log
An empty log after an hour means the cron entry never fired. Check the system cron log with grep CRON /var/log/syslog and confirm the entry is present with sudo crontab -u www-data -l. A missing entry usually means it went into the wrong user’s crontab.
Second, check whether WP-CLI itself failed. Error output lands in the same log file because of the 2>&1 redirect. A “database connection” error points at credentials, and a “command not found” error means the wp path is wrong. Fix the command by hand until it runs clean, then put it back in the crontab.
Third, check the event list. Run wp cron event list and look for the missing event. If it is not listed, the plugin that registered it is not running, which is a plugin problem, not a cron problem. If it is listed with a next run in the past, delete it with wp cron event delete <hook-name> and let the plugin re-register it.
For recurring trouble, add a lightweight health check. A daily server health report sent by cron can include the last lines of the wp-cron log, so a dead scheduler shows up within a day, not weeks later when a post goes missing.
Once the system cron job is in place, the setup needs almost no attention. Check the log weekly for the first month, then monthly. The things that break a system cron wordpress setup are ordinary server changes: a PHP upgrade that moves the wp binary path, a site migration that changes the WordPress root, or a permissions change that leaves www-data unable to read wp-config.php. After any of those, run the WP-CLI command by hand once to confirm it still works.
WordPress cron on a VPS does not need a plugin, a paid service, or an uptime monitor pinging your site every minute. It needs one constant in wp-config.php and one line in a crontab. Set those up, confirm the first few runs in the log, and scheduled tasks will fire on the clock instead of waiting for a visitor who may never come.