Sign up free

Cron · Monitoring

How to know when a cron job stops running

A cron job can stop for many reasons: a full disk, a changed password, a server rebuilt without the crontab, a typo in last week's edit. Nothing breaks visibly. The site is up, the dashboard is green, and the nightly backup hasn't run for two weeks. You find out the day you need it.

Why uptime checks don't catch it

A website check asks "does this URL answer?". A cron job has no URL. The only signal is that something didn't happen, so the check has to run the other way: the job tells the monitor it ran, and the monitor alerts when it hears nothing.

How a heartbeat monitor works

  1. 01

    Create a heartbeat monitor. It gives you a unique URL.

  2. 02

    Your job calls that URL when it finishes successfully.

  3. 03

    If no call arrives within the expected interval plus a grace period, you get an alert. When the job pings again, the monitor recovers.

Add the ping

# crontab: ping only if the job succeeded
0 0 * * * /usr/local/bin/backup.sh && curl -fsS -m 10 https://<heartbeat URL> > /dev/null
# inside a shell script, as the last line
curl -fsS -m 10 --retry 3 https://<heartbeat URL> > /dev/null
# GitHub Actions: last step of the scheduled workflow
- run: curl -fsS -m 10 https://<heartbeat URL>

-f makes curl fail on an error status, -sS keeps it quiet except for errors, -m 10 stops it waiting more than 10 seconds.

Choosing the interval and grace period

Job runsExpected everyGrace
every 5 minutes5 minutes5 minutes
hourly1 hour10 minutes
every 6 hours6 hours30 minutes
nightly1 day1 hour

Grace covers jobs that take a while or start a little late. Make it longer than the job's normal run time.

Jobs that run weekly or monthly can't be watched by a 12happy heartbeat yet: the longest interval is one day.

What the alert looks like

The same channels as your other monitors: email, Slack, Telegram, push, webhook or SMS. Every time is in UTC.

Safe by design

  • The URL takes no API key and changes nothing; it only records "I ran".
  • A mistyped URL returns 404, so it won't look like success.
  • If the URL leaks, rotate it with one API call and the old one stops working at once.

Heartbeat monitors are on Pro ($15 a month, or $12 billed yearly) and Agency. Start free, and upgrade when you add your first job.

Start free

Questions

How do I check if a cron job ran?

Look in the system log (grep CRON /var/log/syslog, or journalctl -u cron). To be told when it doesn't run, use a heartbeat.

Why isn't my cron job running?

The usual causes: the crontab was never saved (crontab -l); a relative path or a missing PATH; the script isn't executable; a time zone you didn't expect.

Can I monitor a job that runs every minute?

Yes. Set the interval to 1 minute and the grace to 2.

Does it work with Kubernetes, GitHub Actions or Windows Task Scheduler?

Yes. Anything that can make an HTTP request when it finishes can ping.