Blog · How-to
How to monitor a cron job with Mortemain (in 3 steps)
Cron runs your job on schedule and says nothing when it stops. Here's how to get alerted instead, in three steps and one line of code.
A cron job that plants in silence or gets removed by a bad deploy tells no one. You notice when the backup, report or sync hasn't run in days. Mortemain fixes that: the job checks in each run, and if a check-in goes missing, you get alerted.
1. Create a check
In your Mortemain account, create a new check:
- Give it a name (e.g. Nightly backup).
- Set the period to how often it should run (e.g. every 24h).
- Add a grace window to absorb normal variation (e.g. 10 minutes), so a slightly late run doesn't false-alarm.
- Copy the ping URL it gives you, like
https://ping.mortemain.com/abc123-xyz456.
2. Add the ping to your crontab
Edit your crontab (crontab -e) and append one curl to the line:
# before 0 3 * * * /usr/local/bin/backup.sh # after 0 3 * * * /usr/local/bin/backup.sh && curl -fsS -m 10 https://ping.mortemain.com/abc123-xyz456
Two things to note: -fsS -m 10 keeps curl quiet, fails on an HTTP error, and times out at 10s; the && means the ping only fires if backup.sh succeeded, so a crashed job never reports a false green.
3. Test it
- Run the script by hand and watch the check flip to up in your dashboard within a second or two.
- Then comment out the crontab line and wait past the period plus grace. The down alert that follows is the whole point.
Want failures reported instantly? Add /start when the job begins and /fail from your error handler, so an errored run pages you at once instead of waiting for the window to lapse:
URL=https://ping.mortemain.com/abc123-xyz456 curl -fsS -m 10 "$URL/start" if /usr/local/bin/backup.sh; then curl -fsS -m 10 "$URL" else curl -fsS -m 10 "$URL/fail"; fi
On a paid plan you can also require signed check-ins (HMAC) so a leaked ping URL can't fake a green.
Not using bare cron?
The idea is identical everywhere; only the exact line changes. The guides have copy-paste code for each:
PowerShell · Python · Kubernetes · Windows Scheduled Tasks · all 30+ guides
Try Mortemain free (20 checks, no credit card).