How to Monitor Cron Jobs: 5 Methods Compared

Each method catches different failures. Here's how to choose.

Five ways to monitor cron jobs: heartbeat URLs, log monitoring, exit code checks, wrapper scripts, and monitoring services. Compare approaches.

Why no single method is enough

Cron jobs fail in several distinct ways, and no single monitoring method catches all of them. A job can fail to run at all (crontab deleted, server down), run but exit with an error (script bug, bad input), run but produce wrong output (logic error, stale data), or run but take too long (hung on a slow dependency). The method you pick determines which of these you'll catch.

In practice, mature setups combine two methods: a heartbeat (dead man's switch) to catch "didn't run" and "ran too long," plus either exit-code checking or output validation to catch "ran but failed." Below are the five common approaches, what each catches, and the trade-offs.

Method 1-2: heartbeat URL and log monitoring

A heartbeat URL is the most reliable way to catch a job that didn't run. Your job pings a URL on success; if the ping is late or missing, you're alerted. It catches server-down, crontab-deleted, and crash-before-ping failures. It doesn't catch a job that runs, pings, but produces wrong output — that needs output validation. SurePing's heartbeat monitors implement this; you add one `curl` line to your job and you're done.

Log monitoring watches the job's log output for error patterns. It catches jobs that run and error, and it gives you the error text for debugging. It doesn't catch jobs that didn't run at all (no log entries to scan), and it requires a log aggregation system and pattern rules. Log monitoring is complementary to heartbeats, not a replacement.

Method 3-5: exit codes, wrapper scripts, and monitoring services

Exit-code checking wraps your job so a non-zero exit triggers an alert. Cron itself emails on non-zero exit (if `MAILTO` is set), but email is unreliable and easy to miss. A wrapper script that captures the exit code and sends it to a monitoring service is more robust. This catches script failures but not "didn't run" failures, so pair it with a heartbeat.

Wrapper scripts combine several checks: they record start/end time, capture exit code, send a heartbeat on success, and alert on failure — all in one shell script around your job. This is the most complete DIY approach but requires you to maintain the wrapper. The fifth method, a dedicated monitoring service, gives you the heartbeat, the alerting, and the dashboard out of the box without writing wrapper logic. SurePing provides heartbeat monitoring with configurable grace periods and webhook alerts on every plan, including Free, so for most teams the monitoring-service approach is the lowest-effort, highest-coverage option.

Monitor this with SurePing

SurePing includes this monitor type on every plan — including the free tier.

Related