Why error alerts miss silent cron failures
Monitor a cron job for silent failures with heartbeat monitoring (a dead man's switch). Append a conditional curl request after && so your script sends an outbound HTTP ping only when it finishes with exit code 0. If the expected ping does not arrive before the grace period expires, your monitor triggers an alert.
Scheduled jobs fail in four ways (Encore): they run and error, never start, hang or overlap, or exit cleanly while doing nothing. Two of those failure modes emit no error output. Classic cron MAILTO also breaks down when a host powers off, loses network access, or lacks a configured local MTA (Healthchecks.io docs).
Heartbeat monitoring flips the check direction. Because the job makes an outbound HTTP request (Testable), you do not expose an inbound health endpoint or open a firewall port.
Setting up a heartbeat ping with curl
Chain a curl ping onto your existing cron command using && so the ping fires only on exit code 0 (Healthchecks.io docs). Always send the success ping after the job verifies its output (Testable), not at startup.
- -f treats non-200 HTTP responses as errors (Healthchecks.io docs).
- -s hides the progress meter while -S keeps error messages visible.
- -m 10 caps the maximum request time at 10 seconds.
- --retry 5 retries transient timeouts or HTTP 5xx responses.
0 2 * * * /usr/local/bin/backup.sh && curl -fsS -m 10 --retry 5 -o /dev/null https://alertondown.com/hb/YOUR_TOKENSetting the interval and grace period
Keep the expected schedule and the grace period separate (Testable). Set the grace period above normal runtime jitter observed over several weeks.
For instance, a job scheduled every 24 hours that takes up to an hour should alert after 26 hours (Encore), and a 14:00 job running 15 to 25 minutes can use a 30 minute grace time so an alert fires at 14:30 (Healthchecks.io docs). Check host timezones with timedatectl status, and verify calendar schedules near 02:30 local time during daylight-saving shifts (Testable).
Catching zero-work runs and hung overlaps
When a script exits 0 without processing records, wrap your verification check before && curl so an empty output file or zero-row query returns a non-zero exit code instead of pinging. Recording per-run counts such as rows processed alongside the job exposes silent drops immediately (Encore).
For overlapping runs where no run ID is sent, guard the script with flock -n and send a start signal so a hung process blocks the next run and triggers a missed-completion alert.
Choosing a heartbeat monitor
Several monitoring tools support curl-based cron heartbeats without requiring an installed server agent:
- Healthchecks.io: dedicated cron monitoring with curl check-ins, start signals, and grace time settings (healthchecks.io/docs/monitoring_cron_jobs/).
- Moonitor: unique HTTP GET heartbeat check-in URL per job with no agent or library required (moonitor.dev/cron-job-monitoring).
- AlertOnDown: bundles cron heartbeat monitors alongside HTTP, SSL, DNS, and multi-ASN uptime checks with Slack, PagerDuty, Telegram, and email alerts, starting on a free tier with 25 active monitors.
Frequently Asked Questions
How can I monitor cron jobs without installing an agent?
Use a heartbeat URL with curl or wget chained after && in your crontab. Because the script sends an outbound HTTP ping on completion, no new server software is needed (Healthchecks.io docs).
Do cron jobs run when the computer is off?
No. If a server powers off or loses network connectivity, cron never fires. Heartbeat monitoring catches powered-off hosts because the expected ping never arrives (Healthchecks.io docs).
Why did my cron alert fire an hour early or late?
A consistent one-hour offset usually points to a timezone mismatch between the server (timedatectl status) and your monitor timezone, or a daylight-saving clock shift (Healthchecks.io docs).
Add a cron heartbeat monitor in 30 seconds
Create a free AlertOnDown workspace with 25 active monitors, copy your /hb/ URL, and alert Slack, PagerDuty, Telegram, or email if a scheduled job ever misses its window.