You scheduled a backup. It ran fine for months. Then one day you need the backup and discover it stopped running three weeks ago. No error. No notification. Nothing.
This is the most common cron failure mode, and it happens because cron has no built-in success confirmation. Here are the most common causes and how to catch each one.
Your script throws an error, but cron doesn't care — it ran the command, its job is done. Unless you've set MAILTO, the error output goes nowhere.
# Bad: errors vanish
0 2 * * * /usr/local/bin/backup.sh
# Better: capture output
0 2 * * * /usr/local/bin/backup.sh >> /var/log/backup.log 2>&1
But logging only helps if you check the logs. Which you won't — not at 2 AM.
Common causes:
/usr/local/bin/backup.sh might not find the tools it needsIn all these cases, MAILTO won't help because the job produces no output — it simply doesn't execute.
The script runs, exits 0, but the database it's backing up was already down. Or the disk is full so the backup file is 0 bytes. Exit code 0 doesn't mean success.
Instead of watching for failures (which are invisible), confirm successes. Add a ping at the end of your job that only fires after the job completes successfully:
0 2 * * * /usr/local/bin/backup.sh && curl -fsS https://ping.trebben.dk/YOUR_SLUG
The && ensures the ping only fires if the script exits 0. A monitoring service watches for the ping. If it doesn't arrive on time, you get an alert.
This catches every failure mode — errors, non-execution, hangs, and silent failures.
#!/bin/bash
# backup-and-verify.sh
set -e
/usr/local/bin/backup.sh
# Verify the backup is actually there and non-empty
BACKUP_FILE="/backups/db-$(date +%Y%m%d).sql.gz"
if [ -s "$BACKUP_FILE" ]; then
curl -fsS https://ping.trebben.dk/YOUR_SLUG
else
echo "Backup file missing or empty!" >&2
exit 1
fi
CronPulse monitors up to 20 cron jobs for free. Email, Slack, webhook, and Telegram alerts. Set up in 30 seconds.
Start monitoring your cron jobs — freeBuilt by Jeff in Denmark. See also: free developer tools.