Alerts and on-call Required
Alert when a scheduled job stops running
Every scheduled job reports when it finishes. Alert when a report is missing, not only when a job fails loudly.
How to do it
At the end of each successful run, send a ping to a heartbeat monitor, such as Healthchecks.io or Cronitor. Make the script stop on the first error, so a failed run sends no ping. Set the expected interval plus a margin, such as 25% of the interval. A job that never starts sends no error, so only a missing heartbeat shows it.
Example
#!/usr/bin/env bash
set -euo pipefail
pg_dump --format=custom shop > /var/backups/shop.dump
curl -fsS --retry 3 https://heartbeat.example.com/ping/nightly-backup
How to check
Stop a job's timer on staging. An alert fires within its interval plus the margin. Make one step fail, and the alert fires the same way.
For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers operations playbook: https://agentwranglers.se/playbook/operations/alerts-and-on-call/job-heartbeats.