Why cron jobs fail silently
A cron job that never starts produces no error and no log line. A server reboot, an expired credential, a full disk or a changed path can stop a job for months, and you find out when you need the backup. Checking from outside cannot help, because there is no URL to check.
How heartbeat monitoring works
Reverse the direction: the job calls a unique URL when it runs. The monitoring service knows the schedule and expects a ping within it plus a grace period. If the ping is late or missing, it alerts. This pattern is also called a dead man’s switch.
Measure run time and report failures
Ping a /start URL when the job begins and the main URL when it succeeds, and the run time is measured — a backup that took 4 minutes for a year and suddenly takes 40 is worth knowing about. Ping /fail when the job catches its own error, so a failure alerts immediately instead of waiting for the grace period.
- •/start when the job begins
- •the ping URL when it succeeds (run time is measured)
- •/fail when it fails
Choose the schedule and grace period
Use the same cron expression and time zone the job uses, and a grace period longer than the job’s normal run time. Too short and you get false alarms on slow nights; too long and you learn late.
Heartbeats in AppStatus
Each AppStatus heartbeat has a private ping URL, or a readable URL with a project key in a header. Schedules are an interval or a cron expression with a time zone, plus a grace period. Get Started has ready snippets for crontab, Linux, macOS, Windows, Python, Node.js, Kubernetes CronJobs and plain curl. Free includes 3 heartbeats, Starter 30, Pro 100.
- •0 2 * * * /usr/local/bin/backup.sh && curl -fsS -m 10 --retry 3 -X POST https://api.appstatus.io/api/v1/heartbeats/ping/<key>