
WP-Cron is convenient, but it isn’t a real scheduler. It only runs when someone loads a page. That’s why backups drift, WooCommerce emails bunch up, and “scheduled post missed” appears at the worst time.
This tutorial shows you how to set up WordPress cron jobs using your server’s cron. Your tasks run on time on a VPS, a dedicated server, or shared hosting with cPanel.
You’ll disable WP-Cron’s page-load trigger. Then you’ll add a system cron that runs due events safely and confirm it’s working.
I’ll also point out the mistakes that cause double-runs, 504s, and stuck queues.
What you’ll build (and what you need)
- Goal: A system cron job that triggers WordPress scheduled events reliably.
- Applies to: WordPress on Nginx/Apache/LiteSpeed, VPS/dedicated, or shared hosting (cPanel cron).
- Access needed: Either SSH access (best) or cPanel Cron Jobs access.
- Time: 20–40 minutes plus testing.
If you run WordPress on a VPS and want consistency under load, full server access keeps this simple. A tuned stack (for example, Nginx + PHP-FPM) also helps.
A HostMyCode VPS gives you that control without turning setup into a side project.
Step 1: Confirm whether WP-Cron is hurting you
Before you change anything, look for these symptoms:
- Scheduled posts miss their publish time.
- WooCommerce emails send late (or in bursts).
- Backups run at random times even though the plugin schedule looks right.
- Page loads spike CPU periodically (especially on busy sites).
Next, confirm you actually have scheduled events waiting to run. If you have WP-CLI, run:
cd /var/www/your-site
wp cron event list --fields=hook,next_run,recurrence --format=table
Verify: You should see core events like wp_version_check and wp_scheduled_delete, plus plugin hooks.
No WP-CLI? You can still follow the steps below. You’ll just have fewer fast ways to test. That matters when you’re troubleshooting.
If you’re also chasing timeouts, don’t assume cron is the only cause. Slow PHP upstreams can look like “cron problems.” This HostMyCode guide helps you separate the two: Fix WordPress 504 Gateway Timeout on Nginx VPS.
Step 2: Disable WP-Cron (the traffic-triggered runner)
Disable WP-Cron’s built-in trigger first. This stops random runs and reduces duplicate execution.
After that, you’ll replace it with a server cron.
Edit your wp-config.php. Typical paths:
- Nginx/Apache on VPS:
/var/www/example.com/public_html/wp-config.phpor/var/www/example.com/htdocs/wp-config.php - cPanel:
/home/USERNAME/public_html/wp-config.php
Add this line above the “stop editing” comment:
define('DISABLE_WP_CRON', true);
Verify: Load your site and confirm everything behaves normally. You’re not “turning off cron.” You’re only stopping the page-load trigger.
Common mistake: Disabling WP-Cron and stopping there. After this change, scheduled tasks will not run until you add a server cron. Keep going.
Step 3: Choose the safest cron method for your hosting
You have two solid options. Pick the one your environment supports:
- Recommended on VPS/dedicated: Run WP-CLI:
wp cron event run --due-now - Works everywhere (including shared hosting): Call
wp-cron.phpvia PHP CLI or HTTP.
Use WP-CLI when you can. It avoids HTTP overhead, behaves predictably, and is easier to trace in server logs.
Step 4 (VPS/dedicated): Create a WP-CLI cron that runs due events
This section assumes SSH access and a working WP-CLI binary. If you’re limited to shared hosting, jump to the cPanel section.
4.1 Install WP-CLI (if needed)
On Ubuntu/Debian (2026), this is a common install pattern:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
php wp-cli.phar --info
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
Verify:
wp --info
If your web server runs as a separate user (often www-data), run cron as that same user. This prevents permission drift.
It also avoids root-owned files showing up in wp-content.
4.2 Create the cron entry
First, decide which user should execute the job:
- Nginx/Apache on Ubuntu: often
www-data - AlmaLinux/Rocky: often
apacheor a per-site user
Edit that user’s crontab. Example for Ubuntu where your WordPress files are owned by www-data:
sudo crontab -u www-data -e
Add a cron line to run every 5 minutes:
*/5 * * * * cd /var/www/example.com/public_html && /usr/local/bin/wp cron event run --due-now --quiet
Verify: Wait up to 5 minutes, then list scheduled events again:
cd /var/www/example.com/public_html
sudo -u www-data wp cron event list --fields=hook,next_run,recurrence --format=table
You should see next_run advance as jobs execute.
Common mistake: Running WP-CLI as root against a site owned by another user. Over time you’ll create root-owned cache or temp files. That can break plugin/theme updates.
Match the site owner.
4.3 Add logging (optional but smart)
Quiet cron is pleasant—until you need proof. If you want a lightweight audit trail, log output to journald:
*/5 * * * * cd /var/www/example.com/public_html && /usr/local/bin/wp cron event run --due-now 2>&1 | /usr/bin/logger -t wp-cron
Verify:
sudo journalctl -t wp-cron --since "1 hour ago"
Step 5 (shared hosting / cPanel): Add a Cron Job safely
On shared hosting, you may not be able to install WP-CLI system-wide. That’s normal.
You can still run scheduled tasks reliably using cPanel’s Cron Jobs.
5.1 Find your WordPress path
In cPanel, open File Manager and locate the folder that contains wp-config.php. A common path is:
/home/USERNAME/public_html
5.2 Create the cron command
In cPanel, go to Cron Jobs and add a new cron. Use one of these command patterns (depending on what your host allows):
Option A: PHP CLI (best if available)
*/5 * * * * /usr/local/bin/php -q /home/USERNAME/public_html/wp-cron.php > /dev/null 2>&1
Option B: HTTP call (works almost everywhere, but avoid if your site uses heavy cron tasks)
*/5 * * * * /usr/bin/curl -sS https://example.com/wp-cron.php?doing_wp_cron > /dev/null 2>&1
Verify: In WordPress Admin, schedule a post for 5–10 minutes ahead. If it publishes on time, your cron is firing.
Common mistakes on shared hosting:
- Using HTTP on a site behind Basic Auth: the cron request gets a 401 and nothing runs.
- Calling cron too often: every minute can trip CPU limits on shared plans.
- Forgetting to disable WP-Cron: you end up with double execution—duplicate emails, repeated cleanup, inconsistent backups.
Step 6: Pick the right interval (and why “every minute” is rarely the answer)
For most sites, every 5 minutes is the sweet spot. Busy WooCommerce stores sometimes need every 1–2 minutes.
Only go that fast if the server has enough CPU and PHP workers.
- Low-traffic blog: every 10–15 minutes is usually fine.
- Membership site / WooCommerce: every 1–5 minutes.
- High-traffic site: every 5 minutes, plus optimize heavy jobs (backups, indexing, marketing sync).
On a VPS you can measure this instead of guessing. Install Netdata and watch CPU load during your cron window: Install Netdata on Ubuntu VPS for Real-Time Monitoring.
Step 7: Validate cron is running (three practical checks)
Don’t settle for “seems okay.” Confirm it with at least one real check.
7.1 Check WordPress scheduled events (WP-CLI)
cd /var/www/example.com/public_html
wp cron event list --format=table
What good looks like: next_run keeps moving forward and overdue events don’t accumulate.
7.2 Force-run due events manually
cd /var/www/example.com/public_html
wp cron event run --due-now
If that command often runs long, the issue is performance, not scheduling. Look for slow plugins, external API calls with long timeouts, or oversized backups.
7.3 Watch server logs during the cron window
For Nginx:
sudo tail -f /var/log/nginx/access.log
If you use HTTP-triggered cron, you’ll see requests for /wp-cron.php. If you use WP-CLI, you won’t. That’s expected.
Step 8: Stop wp-cron.php from being abused
After you switch to system cron, random hits to wp-cron.php are mostly noise. Worse, someone can hammer that URL and create avoidable load.
Approach: Keep your chosen cron trigger working, and limit public access where it makes sense.
8.1 If you trigger cron with WP-CLI
You can safely block web access to wp-cron.php at the server layer.
Nginx example (inside your server block):
location = /wp-cron.php {
deny all;
return 403;
}
Verify:
sudo nginx -t && sudo systemctl reload nginx
curl -I https://example.com/wp-cron.php
You should get 403. Scheduled posts should still publish because cron now runs server-side.
Do not do this if your cron uses HTTP calls. You’ll block your own scheduler.
8.2 If you must use HTTP-triggered cron
Keep wp-cron.php reachable. If you spot abuse, handle it with rate limiting or a WAF at the edge.
On a VPS, you can also block noisy IPs with CrowdSec. This HostMyCode guide walks through it: Install CrowdSec on Ubuntu VPS to Block Bruteforce.
Step 9: Fix the two cron problems that keep coming back
Once a real cron is in place, most “scheduled task” issues vanish. The ones that remain usually fall into two buckets.
9.1 Cron runs, but tasks are still late
That usually means execution is slow, not that scheduling is broken. Common culprits:
- Backup plugins running full-file backups during peak traffic.
- WooCommerce Action Scheduler backlogs.
- Plugins calling third-party APIs with long timeouts.
Quick diagnostic: Force-run due events and time it:
cd /var/www/example.com/public_html
time wp cron event run --due-now
If that routinely takes longer than your interval (say, 7 minutes on a 5-minute schedule), jobs will always drift. Increase resources and/or move heavy work off-peak.
9.2 You get double emails or duplicate tasks
This almost always means WP-Cron is still firing, or you have more than one server cron entry.
Check wp-config.php:
grep -n "DISABLE_WP_CRON" /var/www/example.com/public_html/wp-config.php
Check crontabs:
sudo crontab -l
sudo crontab -u www-data -l
Also confirm your control panel (Plesk/cPanel) didn’t add its own cron on top.
Step 10: WooCommerce stores — keep Action Scheduler from snowballing
WooCommerce relies heavily on scheduled actions. If cron is unreliable, the queue grows and transactional emails lag.
Switching to real cron fixes the trigger. You still need to keep the queue under control.
What to do:
- Use a 1–5 minute cron interval for busy stores.
- Reduce expensive background work during peak hours (search indexing, marketing exports).
- Ensure PHP memory limit is realistic for your store size (often 256–512 MB).
If you’re tuning PHP-FPM for WordPress, run a current PHP version and start from sane defaults. This tutorial is a solid baseline on Ubuntu with Nginx: Install PHP 8.3 on Ubuntu With Nginx and PHP-FPM.
Step 11: Backups — schedule them with cron, then test restores
Plenty of site owners schedule backups and never validate a restore. Cron makes schedules dependable.
It can’t tell you whether the backup is usable.
Minimum routine for 2026:
- Database dump daily.
- Files (or incremental) daily/weekly depending on site changes.
- One tested restore each month (even to a staging folder).
Quick restore test idea: On a VPS, create a staging copy and restore there. This HostMyCode walkthrough is easy to adapt: Create a Staging Copy of WordPress on the Same VPS.
Step 12: If you’re using a control panel, here’s where cron lives
Every panel labels it differently. The underlying idea stays the same.
You’re scheduling a command to run as the correct user, on a reliable interval.
- cPanel: “Cron Jobs” in the Advanced section (use PHP CLI or curl as shown earlier).
- Plesk: “Scheduled Tasks” per subscription (run a command as the subscription user).
- DirectAdmin: “Cron Jobs” under Account Manager.
On managed platforms, ask support to add the cron under the right user. Then ask them to confirm it in logs.
If you don’t want to manage cron, PHP-FPM tuning, and security hardening yourself, managed VPS hosting is often the better value once the site is revenue-critical.
If your WordPress tasks can’t be late—backup windows, WooCommerce emails, membership renewals—run them on hosting where you can control cron behavior. A HostMyCode WordPress hosting plan fits straightforward sites. If you want full control over cron, PHP-FPM, and performance tuning, move up to a HostMyCode VPS.
FAQ: Real cron for WordPress scheduled tasks
Should I run WordPress cron every minute?
Usually no. Start at every 5 minutes. Go to 1–2 minutes only for busy WooCommerce sites, and only if the server can handle it without CPU spikes.
Will disabling WP-Cron break scheduled posts?
Not if you add a server cron. Disabling WP-Cron only stops the “run on page load” behavior. Without a replacement cron, scheduled posts will not publish.
Is WP-CLI better than calling wp-cron.php?
On a VPS or dedicated server, yes. WP-CLI avoids HTTP overhead, is easier to log cleanly, and reduces exposure to public hits on wp-cron.php.
Why are my WooCommerce emails still delayed after switching to real cron?
That typically points to heavy or stuck background tasks (Action Scheduler backlog) or slow external API calls. Time wp cron event run --due-now to see if execution itself is slow.
Can I restrict access to wp-cron.php after switching to real cron?
Yes—if you trigger cron with WP-CLI. If your cron uses curl to hit wp-cron.php, restricting it will stop cron from running.
Summary: reliable WordPress scheduling without wp-cron spikes
Once you disable WP-Cron and switch to system cron, scheduled work no longer depends on traffic. Backups run when they’re supposed to. WooCommerce emails go out consistently.
You also avoid surprise PHP spikes from page-load cron runs.
If you want predictable scheduling with room to grow, run WordPress on infrastructure where you can control cron, PHP, and monitoring—starting with a HostMyCode VPS or stepping up to managed VPS hosting if you’d rather not maintain the stack yourself.