The first sign that a cron job has been silently failing for three months is usually a customer asking where the report went. cron itself does the simple thing: it runs the command, logs the start, captures stdout/stderr, mails the output. None of that tells your monitoring stack whether the command exited zero, took 40 minutes when it normally takes 4, or didn’t run at all because the host was down at midnight.
What’s happening
A working cron monitor needs to answer three questions, not one:
- Did the job run? A missed schedule is a separate failure mode from a run that returned non-zero.
- Did it exit cleanly? Exit code zero, but only zero — not “the command exists.” Many shell-pipe jobs return zero even when an upstream command in the pipe failed, unless
pipefailis set. - Did it run within expected duration? A backup that normally takes 10 minutes and suddenly takes 4 hours is broken, even if it eventually exits zero.
The pattern is dead-man’s-switch monitoring: the job checks in with a monitoring endpoint at start, on success, and on failure. If the success check-in doesn’t arrive within an expected window, the monitoring system fires the alert. This inverts the usual “alert on bad signal” pattern into “alert on missing good signal” — which is the only way to catch jobs that didn’t run at all.
How to verify
Wrap the cron command. A minimal pattern:
0 2 * * * /usr/local/bin/run-with-heartbeat backup-prod
Where run-with-heartbeat:
#!/bin/bash
set -euo pipefail
JOB="$1"; shift
PING="https://hc-ping.example/${JOB}"
curl -fsS --retry 3 "${PING}/start" >/dev/null
start=$(date +%s)
if "$@"; then
duration=$(( $(date +%s) - start ))
curl -fsS --retry 3 --data-raw "duration=${duration}" "${PING}" >/dev/null
else
rc=$?
curl -fsS --retry 3 "${PING}/fail" >/dev/null
exit $rc
fi
Configure the monitoring service with the schedule expectation (cron expression plus a grace window — for a job that runs at 02:00 daily and takes up to 30 minutes, the expected check-in is “02:00 daily, grace 60 minutes”). The service alerts on missed check-ins as well as explicit failures.
For ad-hoc verification on a specific host, journalctl -u cron.service (or /var/log/cron on cPanel) shows actual cron invocations. If a job doesn’t appear there, cron itself isn’t firing it — common causes are a syntax error in the crontab and the user account being suspended.
The fix
Wrap every business-critical cron job with start/success/fail check-ins to a dead-man’s-switch service (Healthchecks.io, Cronitor, or self-hosted). Configure schedule expectations with grace windows that match observed durations. Drop the legacy “MAILTO” approach as the primary signal — it does not survive a mail outage and nobody reads it.
Stack Harbor’s Monitoring & Support practice instruments cron-driven workflows as part of onboarding, including the long-tail jobs nobody documented. If you don’t know which crons are running on your hosts right now, we can find out — or see how scheduled-job hygiene fits with environment management.