How to Replace WordPress WP-Cron with a Real System Cron Job Safely

WordPress uses its built-in WP-Cron system to publish scheduled posts, clean up expired transients, run backup plugins, and dispatch WooCommerce follow-up tasks. Unlike a real server cron daemon, however, WP-Cron only triggers when someone visits an uncached WordPress PHP page. On low-traffic sites—or sites heavily cached behind Cloudflare—scheduled posts miss their publish window completely; on busy sites, concurrent visitors can trigger redundant loopback requests to wp-cron.php. Switching to a real system cron job fixes both problems cleanly.

Editorial illustration comparing default WordPress WP-Cron with system cron and DISABLE_WP_CRON

Editorial illustration: disable traffic-triggered WP-Cron in wp-config.php and schedule a reliable 5-minute system timer instead.

Summary

  • Per the WordPress Plugin Handbook on Hooking WP-Cron Into the System Task Scheduler, default WP-Cron runs only on page loads and does not run continuously on a fixed clock.
  • Define define( 'DISABLE_WP_CRON', true ); in wp-config.php to stop WordPress from spawning loopback HTTP requests during visitor page loads.
  • Schedule a real system cron job (crontab -e on Linux or hosting control panel Cron Jobs) every 5 minutes—using either wp cron event run --due-now (via WP-CLI, avoiding HTTP timeouts) or curl -s https://example.com/wp-cron.php?doing_wp_cron.
  • Confirm Tools > Site Health still shows scheduled events running cleanly after the switch, noting per WP_Site_Health that Site Health still warns if a scheduled event falls significantly behind.

Why default WP-Cron breaks on modern hosting

Two opposite situations break default WP-Cron:

  1. Heavy Cloudflare or page caching: If 99% of anonymous traffic hits Cloudflare’s edge cache (cf-cache-status: HIT), WordPress PHP never executes on those visits—so _wp_cron() never fires until an editor logs in.
  2. Traffic spikes: When 50 uncached requests arrive at the same second as a due cron task, WordPress can waste PHP workers checking or spawning wp-cron.php loopback requests (and if your server blocks loopback HTTP calls or sits behind Cloudflare Access/Basic Auth, wp-cron.php loopbacks fail silently).

Step-by-step: Move WordPress cron to system cron

1. Back up wp-config.php and test on staging

Always verify a clean backup first (see WordPress backup restore rehearsal) before editing wp-config.php.

2. Disable traffic-driven WP-Cron in wp-config.php

Open wp-config.php and add this line above /* That's all, stop editing! Happy publishing. */:

define( 'DISABLE_WP_CRON', true );

As shown in _wp_cron(), setting DISABLE_WP_CRON to true stops WordPress from firing wp-cron.php on normal visitor page loads, while still allowing manual or system-triggered wp-cron.php / WP-CLI runs to execute due events.

3. Add a real system cron job every 5 minutes

Option A (Recommended on VPS / SSH with WP-CLI): Running via WP-CLI executes directly in PHP CLI, avoiding Nginx/Cloudflare HTTP timeouts on heavy tasks:

*/5 * * * * cd /var/www/html && /usr/local/bin/wp cron event run --due-now >/dev/null 2>&1

Option B (Shared hosting / cPanel / Plesk without WP-CLI): Use your host’s Cron Jobs panel to hit wp-cron.php every 5 minutes:

*/5 * * * * curl -fsS -m 60 "https://example.com/wp-cron.php?doing_wp_cron" >/dev/null 2>&1

(If your site uses Cloudflare Access on /wp-cron.php or aggressive bot rules, prefer Option A with WP-CLI over localhost/CLI so Cloudflare edge rules never block your own cron.)

4. Verify cron events and Site Health

After waiting 5–10 minutes:

  1. Run wp cron event list (or check Tools > Site Health) to confirm no events are piling up in overdue status—see our WordPress Site Health action plan.
  2. Confirm scheduled transients cleanup and backup jobs execute on time; keeping expired transients pruned also helps avoid database bloat covered in using the WordPress Transients API safely.

Common mistakes

  • Setting DISABLE_WP_CRON to true without actually creating the system cron job. Every scheduled post, WooCommerce subscription renewal, and transient cleanup stops immediately!
  • Running wp-cron.php every 10 seconds instead of every 5 minutes. Over-frequent cron runs can overlap long-running backup or sync jobs and spike CPU. Five minutes (or one minute on high-volume WooCommerce stores) is plenty for most sites.
  • Forgetting to run WP-CLI cron as the web user (www-data or site user). Running wp cron event run as root can create cache or log files owned by root that PHP-FPM cannot overwrite later—use the site’s normal web user crontab (crontab -u www-data -e).
  • Assuming ALTERNATE_WP_CRON is better than system cron. ALTERNATE_WP_CRON appends ?doing_wp_cron=... query strings to visitor URLs via redirects, which breaks clean caching and SEO URLs—use a real system cron instead whenever your host allows it.

Why this matters

Moving WordPress cron off visitor page loads makes scheduled publishing reliable even when Cloudflare caches 99% of your HTML, while keeping origin PHP workers focused on serving real users.

My Take

On any WordPress site running behind Cloudflare or serving WooCommerce orders, disabling WP_Cron on page loads and running wp cron event run --due-now every 5 minutes via system cron (under the web user account) is one of the highest-impact stability upgrades you can make in five minutes.

Conclusion

Add define( 'DISABLE_WP_CRON', true ); to wp-config.php, schedule a 5-minute system cron job using WP-CLI (wp cron event run --due-now) or curl under the proper web user, and verify in Tools > Site Health that scheduled tasks stay current.

Sources