Guide
How to monitor cron jobs (and know when one silently stops)
· 6 min read · Facts checked December 2, 2026
Short answer
Monitor a cron job with a heartbeat: at the end of each successful run, the job requests a unique URL (curl https://…/hb/<token>). A monitoring service expects that ping on the job's schedule, plus a grace period, and alerts you when it's late. That catches every kind of failure, including the job never starting, which logs and error emails can't.
Cron is wonderfully simple and terrible at telling you when something goes wrong. If the job crashes, cron may email the output to a local mailbox nobody reads. If the job never starts, because the server was replaced, the crontab was overwritten during a deploy, or the container that ran it was scaled to zero, nothing happens at all. You find out weeks later, when you need the backup that hasn't been taken since March.
This guide covers why cron jobs fail silently, the ways to monitor them, and how to set up heartbeat monitoring in a few minutes.
Why cron jobs fail silently
The usual ways a scheduled job stops doing its work:
- It never runs. The server is down or was rebuilt without the crontab, the cron daemon isn't running, a deploy replaced the crontab, a Kubernetes CronJob is suspended, or the schedule is wrong. Check a schedule with our cron expression translator:
0 0 * * 1and0 0 1 * *look similar and mean very different things. - It runs, but in the wrong environment. Cron starts jobs with a minimal
PATHand environment. A script that works in your shell fails under cron because it can't findnode,pythonorpg_dump, or doesn't have the environment variables it expects. - It fails partway. The database dump hits a full disk, an API returns an error, credentials expire. If the script doesn't exit with an error, or nobody reads the error, it looks like success.
- It runs too long. A job that used to take two minutes now takes two hours and overlaps with the next run, or gets killed by a timeout.
- It succeeds but does nothing. An empty export, a backup of zero bytes. Only a check on the result catches this.
Cron itself reports none of these in a way you'll see.
Ways to monitor cron jobs
1. Cron's own email (MAILTO)
Set MAILTO=you@example.com at the top of the crontab and cron emails any output a job produces. It's better than nothing, but it only works if the server can send mail, it's noisy (every line of output becomes an email), and it says nothing when a job doesn't run at all.
2. Logs and log alerts
Redirect output to a log file (>> /var/log/backup.log 2>&1) or a logging service, then alert on error lines. This tells you why a job failed, which is valuable. But like MAILTO, it can't alert on the absence of a run: no run, no log line, no alert, unless you build "expected a line by 03:10" rules, which is a heartbeat in disguise.
3. Heartbeat monitoring (a dead man's switch)
Flip it around: instead of waiting for an error, expect a sign of life. The job pings a unique URL when it finishes successfully. The monitoring service knows the schedule and raises an alert when the ping is late. This is called a heartbeat, a check-in or a dead man's switch, and it's the only method that catches all the failures above, including the job never starting.
Heartbeats work for anything that runs on a schedule: crontab entries, Kubernetes CronJobs, systemd timers, GitHub Actions schedules, Windows Task Scheduler, a queue worker that should process something every few minutes.
Setting up a heartbeat, step by step
Here's the setup with Uptenna heartbeats; other heartbeat services work much the same way.
1. Create the heartbeat. Choose how often the job runs (Uptenna supports from every 5 minutes to once a week) and a grace period: extra time before a run counts as late. The grace period covers normal variation in run time; 20% of the period is the default.
2. Copy the ping URL. Each heartbeat gets a unique URL like https://uptenna.com/hb/<token>. Treat it as a secret: anyone with the URL can ping it.
3. Ping it at the end of the job, only on success. In a crontab, chain it with && so it only runs when the job exits with status 0:
# Every night at 03:00
0 3 * * * /usr/local/bin/backup.sh && curl -fsS -m 10 --retry 3 https://uptenna.com/hb/<token>The curl flags matter: -f fails on HTTP errors, -sS is quiet but still shows errors, -m 10 caps the request at 10 seconds so a network problem can't hang the job, and --retry 3 survives a brief blip.
4. Report failures straight away (optional). Without this, a failed job is noticed when the next ping is late. To be alerted immediately, ping the failure URL when the job exits with an error:
/usr/local/bin/backup.sh && curl -fsS -m 10 https://uptenna.com/hb/<token> || curl -fsS -m 10 https://uptenna.com/hb/<token>/fail5. Ping from code, if the job is a script. At the very end, after the work is verified:
// Node 18+: at the end of the job, after the work succeeded
await fetch(`https://uptenna.com/hb/${process.env.UPTENNA_HEARTBEAT}`);import os, urllib.request
# ... the job's work ...
urllib.request.urlopen(f"https://uptenna.com/hb/{os.environ['UPTENNA_HEARTBEAT']}", timeout=10)6. Test it. Run the job by hand and watch the heartbeat turn healthy. Then let one run go late on purpose (or ping /fail) and make sure the alert arrives where you'll see it.
When a heartbeat is late, Uptenna opens an incident and alerts you; the next successful ping resolves it and sends a recovery. Alerts go to email on every plan, and to Slack, Discord, Telegram or a signed webhook on Pro and Team.
Choosing the period and grace period
- Period: the job's schedule. For
*/15 * * * *, 15 minutes; for0 3 * * *, one day. - Grace: the longest normal run time plus a margin. If the backup usually takes 10 minutes and sometimes 25, a 30 to 40 minute grace avoids false alarms.
- Irregular schedules (weekdays only, the first of the month): set the period to the longest normal gap, or accept that the heartbeat checks for "at least once per period".
Beyond "did it run": checking the result
A heartbeat proves the job finished. To catch jobs that succeed but do nothing useful, make the script check its own output before pinging:
pg_dump mydb > /backups/db.sql \
&& test -s /backups/db.sql \
&& curl -fsS -m 10 https://uptenna.com/hb/<token>test -s fails on an empty file, so an empty dump never sends the ping, and you're alerted.
Common mistakes
- Pinging at the start of the job. That only proves the job started. Ping at the end.
- Pinging with
;instead of&&.job; curl …pings even when the job failed. - No timeout on the ping. Without
-m 10, a network problem could hang your job waiting for the monitor. - Grace period too tight. Alerts every time the job is a bit slow train you to ignore them.
- One heartbeat for many jobs. Give each job its own URL so you know which one stopped.
- Forgetting the time zone. Cron uses the server's time zone; GitHub Actions uses UTC. A heartbeat expecting 03:00 local time and a job running at 03:00 UTC will disagree twice a year, or always.
Getting started
Uptenna's free plan includes 5 monitors, and heartbeats count as monitors, so you can watch your most important jobs (and the sites they serve) with email alerts at no cost. New accounts start with 14 days of Pro, no card. Free HTTP checks run every 5 minutes; heartbeats are judged against their own schedule.
Frequently asked questions
What is a cron job heartbeat?
A ping the job sends to a monitoring service each time it completes. If the service doesn't receive the ping on schedule (plus a grace period), it alerts you. It's also called a check-in or dead man's switch.
How do I get notified when a cron job fails?
Ping a heartbeat URL after the job succeeds (job && curl …), and optionally a failure URL when it fails (|| curl …/fail). A missing or failure ping triggers an alert. Cron's MAILTO can email output, but it can't tell you when a job doesn't run at all.
How do I monitor a Kubernetes CronJob?
Add the ping to the container's command after the work, for example sh -c 'run-job && curl -fsS -m 10 https://uptenna.com/hb/<token>', or call the URL from your code at the end of the job. The heartbeat then catches failed pods, suspended CronJobs and missed schedules.
Is heartbeat monitoring free on Uptenna?
Yes. Heartbeats are included on every plan and count toward the monitor limit (5 on Free). Free alerts go by email; Pro adds Slack, Discord, Telegram and webhooks.