WP-Cron WordPress Monitoring
Master WP-Cron monitoring for reliable WordPress
WordPress powers over 40% of websites worldwide. Behind every WordPress site is WP-Cron, the scheduled task system that handles everything: from scheduled posts to automatic backups, email sending, and plugin updates. When WP-Cron stops working, the consequences can be disastrous.
Unlike Linux system cron, WP-Cron doesn't run autonomously. It depends on site visits to execute, creating a fundamental problem: a low-traffic site can have tasks delayed by several hours. Additionally, aggressive caching plugins can completely block WP-Cron execution with no alert.
The recommended solution is to disable native WP-Cron in favor of a system cron, then monitor that cron with MoniTao. This approach guarantees reliable and predictable execution of your WordPress tasks, regardless of your site's traffic.
Common WP-Cron Problems
The WP-Cron mechanism has several technical limitations that impact the reliability of your scheduled tasks:
- Visit dependency: WP-Cron only executes when a visitor loads a page. A site with little traffic can see its tasks delayed by several hours, or even forgotten completely.
- Cache blocking: Caching plugins (WP Super Cache, W3 Total Cache, LiteSpeed) can intercept requests and serve static pages, preventing WP-Cron from executing.
- Performance impact: WP-Cron checks and executes pending tasks on every page load, adding noticeable latency for visitors, especially when heavy tasks are triggered.
- Task accumulation: If WP-Cron doesn't run for several hours, tasks accumulate and may all execute simultaneously on the next visit, overloading the server.
Best Practice: System Cron
The professional solution is to replace WP-Cron with a reliable system cron:
- Disable native WP-Cron: Add define('DISABLE_WP_CRON', true); to your wp-config.php file. This prevents WordPress from checking tasks on every page load.
- Configure system cron: Add a crontab entry that calls wp-cron.php every 5 minutes: */5 * * * * wget -q -O /dev/null https://your-site.com/wp-cron.php?doing_wp_cron
- Monitor with MoniTao: Create a MoniTao heartbeat for this system cron. If the cron doesn't execute, you'll be alerted immediately instead of discovering the problem days later.
Critical WordPress Tasks
These WordPress tasks depend on WP-Cron and require particular monitoring:
- Scheduled posts: Articles scheduled for a future date will only be published if WP-Cron works. A failure means an article stuck in draft when it should be live.
- Automatic backups: Plugins like UpdraftPlus, BackWPup, or Jetpack Backup schedule their backups via WP-Cron. A failing WP-Cron means missing backups.
- Emails and newsletters: Email plugins (MailPoet, Newsletter, etc.) use WP-Cron to send emails in batches. A blockage can delay your campaigns by several hours.
- Automatic updates: WordPress checks and applies security updates via WP-Cron. A broken WP-Cron can leave your site vulnerable to known vulnerabilities.
Heartbeat Integration Example
Here's how to integrate a MoniTao heartbeat directly into your WordPress tasks:
// In functions.php or a custom plugin
// Create a custom hook for the heartbeat
add_action('monitao_hourly_heartbeat', 'monitao_send_heartbeat');
function monitao_send_heartbeat() {
$ping_url = 'https://api.monitao.com/ping/your-token';
$response = wp_remote_post($ping_url, [
'timeout' => 10,
'body' => json_encode(['status' => 'ok']),
'headers' => ['Content-Type' => 'application/json']
]);
if (is_wp_error($response)) {
error_log('MoniTao heartbeat failed: ' . $response->get_error_message());
}
}
// Schedule the heartbeat (if not already scheduled)
if (!wp_next_scheduled('monitao_hourly_heartbeat')) {
wp_schedule_event(time(), 'hourly', 'monitao_hourly_heartbeat');
}
This code creates a WP-Cron task that pings MoniTao every hour. If the ping stops arriving, MoniTao alerts you that your WP-Cron is no longer working. You can adapt the interval (hourly, twicedaily, daily) according to your needs.
WordPress Monitoring Strategies
Several complementary approaches allow you to effectively monitor your WordPress tasks:
- System cron + MoniTao: The recommended method: your system cron calls wp-cron.php, then pings MoniTao. You monitor the cron execution, not WordPress directly.
- Direct WordPress hook: Add a MoniTao ping at the end of your critical tasks (backup, newsletter sending) to confirm their effective execution.
- HTTP monitoring: Monitor the wp-cron.php URL with a MoniTao HTTP monitor. A 500 error or timeout indicates a server-side problem.
- Diagnostic plugins: WP Crontrol or WP-Cron Dashboard allow you to see pending tasks and their status, but don't replace external monitoring.
Debugging WP-Cron
When WP-Cron doesn't work as expected, use these diagnostic techniques:
- WP-CLI: The command wp cron event list displays all scheduled tasks with their next execution. wp cron event run --due-now forces execution of overdue tasks.
- WP Crontrol plugin: This free plugin displays a visual interface of all WP-Cron tasks, allows manual execution, and helps diagnose problematic hooks.
- ALTERNATE_WP_CRON: If your host blocks loopback calls, add define('ALTERNATE_WP_CRON', true); to wp-config.php to use an alternative redirect method.
- Server logs: Check access.log for calls to wp-cron.php and error.log for PHP errors. A cron that doesn't execute won't appear in the logs.
WP-Cron Checklist
- Add DISABLE_WP_CRON to wp-config.php
- Configure system cron to call wp-cron.php
- Create a MoniTao heartbeat for this cron
- Identify all critical tasks (backups, emails)
- Install WP-CLI or WP Crontrol for diagnostics
- Manually test a wp-cron.php execution
Frequently Asked Questions
My scheduled posts don't publish at the scheduled time. Why?
WP-Cron wasn't triggered between the scheduling moment and publication time. Without traffic on your site (or with aggressive caching), WP-Cron stays inactive. The solution: disable native WP-Cron and configure a system cron that calls wp-cron.php every 5 minutes.
WP-Cron slows down my site. How can I optimize it?
Native WP-Cron runs on every page load, adding latency. By adding DISABLE_WP_CRON and using a system cron, you completely remove this overhead. Visitors no longer trigger scheduled tasks, which significantly improves response times.
How can I see pending WP-Cron tasks and their status?
Install the WP Crontrol plugin from the WordPress repository. It displays all scheduled tasks, their hook, their next execution, and allows manual execution. From the command line, use wp cron event list with WP-CLI.
My UpdraftPlus backup doesn't run automatically. What should I do?
UpdraftPlus depends entirely on WP-Cron. First check that WP-Cron is working by consulting the UpdraftPlus > Settings > Advanced page. If "Unable to use WP-Cron" appears, configure a system cron. Then monitor this cron with MoniTao to be alerted if backups stop.
My shared hosting doesn't allow crons. What alternatives exist?
Several solutions exist: use a free external cron service (cron-job.org, EasyCron) to call your wp-cron.php, or use ALTERNATE_WP_CRON mode which bypasses certain limitations. MoniTao can monitor these external calls to guarantee their reliability.
How do I know if WP-Cron is working correctly?
Create a MoniTao heartbeat that pings from a WP-Cron task (see code example). If the ping stops, WP-Cron is down. You can also manually check by calling https://your-site.com/wp-cron.php?doing_wp_cron in your browser and checking the server logs.
Reliable WordPress with Monitored Cron
WP-Cron is a simple but fragile system, designed for sites with regular traffic. In reality, many WordPress sites have irregular traffic or use aggressive caching that makes WP-Cron unreliable. The consequences range from unpublished posts to missing backups.
The professional solution combines a reliable system cron with external MoniTao monitoring. This approach guarantees that your WordPress tasks execute according to the planned schedule, and alerts you immediately in case of problems. Start by monitoring your most critical tasks: backups and scheduled publications.
Ready to Sleep Soundly?
Start free, no credit card required.