Published October 21, 2026
How to Monitor Cron Jobs (and Catch the Ones That Never Run)
Most monitoring is built to notice when something goes wrong. Cron jobs are tricky because their worst failure is that nothing happens. The job doesn't start, so there's no error, no log line, and no alert. You find out when a customer asks why last night's report is missing or when you need a backup that stopped being written two weeks ago.
This guide covers the ways people monitor cron jobs, what each one misses, and how to set up the approach that catches everything: a heartbeat.
The four ways cron jobs fail
It helps to name the failure modes, because each monitoring method only catches some of them.
- It ran and failed. The script exited non-zero: a database was down, a disk was full, or an API returned 500.
- It never ran. The server was off, the cron daemon died, the crontab was overwritten in a deploy, or the schedule was wrong.
- It ran late or hung. A lock wasn't released, a network call never timed out, or the run took three hours instead of three minutes.
- It "succeeded" but did nothing. The script exited 0, but processed zero rows because an upstream export was empty.
Common approaches and what they miss
| Method | Catches | Misses |
|---|---|---|
| Reading logs | 1, sometimes 3 | 2 (no run, no log), and nobody reads logs proactively |
MAILTO email |
1, if output is produced and mail works | 2, 3; often lands in spam or a dead inbox |
| Exit-code wrappers that alert on failure | 1 | 2, 3 |
| Log-based alerting (e.g. "alert on ERROR") | 1 | 2, 3, 4 |
| Heartbeat / dead man's switch | 1, 2, 3, and 4 if you ping conditionally | needs one line of setup per job |
The key insight: any method that relies on the job reporting a problem can't catch a job that never started. You need something outside the job that expects to hear from it and notices the silence.
The heartbeat pattern
A heartbeat check (also called a dead man's switch) flips the logic:
- You tell a monitor: "This job runs every day at 03:00. Allow 15 minutes of grace. If you haven't heard from it by 03:15, alert me."
- At the end of each successful run, the job sends a request to a unique URL.
- If the request doesn't arrive inside the window, you get an alert.
Since the alert fires on absence, it covers every failure mode: a crash, a dead server, a deleted crontab, a hung process. All of them result in no ping.
The one-line version
0 3 * * * /usr/local/bin/backup.sh && curl -fsS -m 10 --retry 3 https://cronnudge.com/ping/<check-id> > /dev/null
What each piece does:
&&sends the ping only ifbackup.shexits 0, so a failed run is treated like a missed run.-fmakes curl fail on HTTP errors,-sSstays quiet but still shows errors.-m 10caps the request at 10 seconds so a network problem can't hang your job.--retry 3rides out a brief network blip.
Choosing the schedule and grace period
Set the expected schedule to match the crontab. CronNudge's default grace is 5 minutes (300 seconds). The check form offers none, 1 minute, 5 minutes, 15 minutes, and 1 hour. The API accepts any whole number of seconds from 0 through 7 days. A short daily backup can use the 15-minute option. A job every 5 minutes can use the 5-minute default. Free will not accept a schedule more often than every 5 minutes. Pro's minimum is 1 minute. Too tight and you get false alarms. Too loose and you hear about problems late.
The ping URL is https://cronnudge.com/ping/<check-id>. The id is that check's ping id, not a short public slug. GET, POST, and HEAD all count, and the response is text/plain ok with Cache-Control: no-store. /start and /fail are the same URL with that suffix. A non-zero ?exit= on the success URL is a failure. POST /fail from an error path if you want the alert immediately. Otherwise silence after grace is the alert. CronNudge sends one alert when the check is down and one when it recovers.
Setups for common languages
Bash, with failure details in your logs
#!/usr/bin/env bash
set -euo pipefail
PING_URL="https://cronnudge.com/ping/<check-id>"
main() {
pg_dump --format=custom "$DATABASE_URL" > "/backups/db-$(date +%F).dump"
find /backups -name 'db-*.dump' -mtime +14 -delete
}
main
# Only reached if main succeeded, because of set -e
curl -fsS -m 10 --retry 3 "$PING_URL" > /dev/null || echo "heartbeat ping failed" >&2
The || echo keeps a ping failure from marking your successful backup as failed. If the ping doesn't land, the monitor will tell you, which is the safe direction to fail.
The script above redirects pg_dump straight to a file, so the exit status is pg_dump's. A pg_dump | gzip pipeline is a different status, and a dump that exits 0 can still be the wrong size. Both are in monitor database backup cron jobs.
Python
import urllib.request
PING_URL = "https://cronnudge.com/ping/<check-id>"
def main() -> int:
rows = sync_orders() # your job
return rows
if __name__ == "__main__":
rows = main() # an exception here means no ping
if rows > 0: # catch "succeeded but did nothing"
try:
urllib.request.urlopen(PING_URL, timeout=10)
except Exception as e:
print(f"heartbeat ping failed: {e}")
The rows > 0 check handles failure mode 4. Only ping when the job did real work, if "zero rows" is abnormal for that job.
Node.js (18+)
const PING_URL = "https://cronnudge.com/ping/<check-id>";
async function main() {
const sent = await sendDigestEmails(); // your job
if (sent === 0) throw new Error("no digests sent");
}
main()
.then(() => fetch(PING_URL, { signal: AbortSignal.timeout(10_000) }))
.catch((err) => {
console.error(err);
process.exitCode = 1; // no ping on failure
});
Practices that make cron jobs easier to monitor
Prevent overlapping runs. If a job can run longer than its interval, two copies can collide. Use flock:
*/5 * * * * /usr/bin/flock -n /tmp/sync.lock /usr/local/bin/sync.sh && curl -fsS -m 10 https://cronnudge.com/ping/<check-id>
With -n, a second copy exits immediately instead of piling up. Because the && only pings when sync.sh actually runs and succeeds, a job stuck holding the lock stops pinging, and you'll hear about it. Two hosts, a Kubernetes Allow policy, and a retry are a different problem than this one lock. Those are in prevent overlapping cron jobs. Two starts at the same minute, from a second crontab or a second scheduler, are in cron job running twice.
Put a timeout on the job itself. timeout 30m /usr/local/bin/report.sh kills a run that hangs, so it shows up as a failure instead of blocking the next run forever. Exit status 124, --kill-after, and a stuck-run alert are in cron job stuck or hanging.
Keep logs anyway. A heartbeat tells you that something broke. Logs tell you why. Redirect output to a file or your log pipeline: >> /var/log/app/report.log 2>&1.
One check per job. Don't share a ping URL between jobs. If one stops and the other keeps pinging, the silent failure is hidden.
Monitor the monitor-free places. WordPress misses the same way when no PHP request spawns WP-Cron: WP-Cron not running. Cron isn't the only scheduler. Kubernetes CronJobs, Argo CronWorkflows, systemd timers, GitHub Actions schedules, GitLab scheduled pipelines, Jenkins Pipeline schedules, CircleCI scheduled pipelines, Vercel Cron, Supabase pg_cron, Celery beat, APScheduler, Airflow Dag schedules, Prefect flow schedules, Dagster schedules and sensors, Spring scheduled tasks, Quartz Scheduler, Hangfire recurring jobs, Rails scheduled jobs, Render, Railway, and Fly.io, Heroku Scheduler, EventBridge schedules, BullMQ, node-cron, and Agenda, Cloud Scheduler and Cloud Run, Firebase scheduled functions, Azure Functions timer triggers, and AI agents on a timer all fail silently in the same way, and the same heartbeat line works for all of them.
What to alert on, and where
- Missed or late ping: always. This is the main signal.
- Recovery: useful, so you know when to stop worrying.
- Route by importance. Backups and billing jobs should go to a channel someone watches. Free includes email and one Slack or Discord integration. Signed webhooks are on Pro. There is no native pager integration, and no SMS or phone alert. DIY webhook payloads, and what an in-job alert misses, are in Slack or Discord alerts when a cron job fails.
Avoid sending every alert to an inbox nobody reads. A silent alert is as bad as no alert.
Build it yourself vs. use a service
You can build a basic dead man's switch yourself: a tiny endpoint that records the last ping time, plus a second scheduled job that checks for stale timestamps. The catch is that your checker is another cron job that can silently fail too, so it needs to run somewhere independent of the jobs it watches. For a few jobs, a hosted service is usually less work. Self-hosted open-source options like Healthchecks.io exist if you want to run it yourself.
FAQ
What is a dead man's switch for cron? A monitor that expects a regular signal from your job and alerts you when the signal stops. It's named after the train-driver device that stops the train if the driver lets go.
Is checking the exit code enough? No. An exit code only exists if the job ran. It can't tell you about a job that never started.
Should the ping go at the start or the end of the job? The end, after the work succeeds. A ping at the start only proves the job began.
What if the monitoring service is down when my job pings?
Use --retry and a short timeout so your job isn't affected. A missed ping errs on the side of an alert, which is the safe direction.
How many cron jobs should I monitor? Every job whose silent failure would cost you something: backups, billing, data syncs, cleanups that prevent disks from filling, and scheduled emails.
Does this work for jobs that aren't cron? Yes. Anything that can make an HTTP request on a schedule can send a heartbeat.
CronNudge is a hosted heartbeat monitor. Free covers 10 checks, with email and one Slack or Discord channel. Pro is $12 a month for 100 checks, and adds signed webhooks and the API. Add your first check.