When should a job send its heartbeat?
Healthchecks.io's How to Monitor Cron Jobs documents notifications when a scheduled job's expected completion ping does not arrive.
A backup job can stop running while the website continues to return successful pages. The same is true for imports, report generation, cache warming, certificate renewal tasks and scheduled maintenance scripts. A successful response from an unrelated web page does not establish that a scheduled job ran. Check the job’s recorded completion state or its expected heartbeat.
The Healthchecks.io cron-job guide describes the job sending an HTTP ping when it completes, with notifications for a missing ping after the configured grace time. It calls this heartbeat monitoring a type of dead man's switch. This is the documented Healthchecks.io example, not a universal service contract.
The signal should represent meaningful progress. For your success rule, treat a start signal as evidence of the reporting step, not completion of the job. For backups, the most useful completion signal normally follows a successful write and any required verification.
What schedule, delay and success rule should you set?
Write down the expected schedule, tolerated delay, success point, timezone and owner. Include daylight-saving behavior and long-running jobs. A daily task expected at 02:00 should not alert at 02:01 if normal completion takes forty minutes.
- Expected schedule and timezone are explicit.
- The grace window reflects real execution time.
- The heartbeat is sent only after the chosen success condition.
- For failure-signal selection, require documentation of a distinct failure signal when appropriate.
- The alert identifies the job, client, last success and owner.
How can you add a heartbeat without hiding a job failure?
The heartbeat call must not turn a successful job into a failure without an intentional policy, and it must not overwrite the job's real exit status. Use bounded network timeouts. Keep the heartbeat endpoint secret because anybody who can call it may be able to create a false success signal.
Treat each endpoint as a credential. Store it in a secret manager or environment configuration, limit who can read it and rotate it after exposure.
For high-value jobs, consider a second verification such as checking the age, size or integrity of the output. A completion ping from a script bug can otherwise report success before the expected artifact exists.
Who needs the missed-job alert?
A missed image-optimization task may wait for business hours. A missed database backup may require immediate triage. Apply severity based on the protected outcome rather than giving every scheduled job the same route.
Include the last successful completion, current overdue duration, recent schedule changes and first-response instruction. Avoid repeatedly notifying the same overdue job unless escalation rules require it.
Test failure and recovery
- Use a safe non-production job or approved test schedule.
- Confirm a successful completion records exactly one heartbeat.
- Suppress the heartbeat and verify the alert after the grace window.
- Restore the signal and verify recovery is recorded once.
- Check that the original job exit code and logs remain intact.
- Record the test date and owner.
Never create a production failure test against a client system without explicit authorization and a rollback plan.
References
- Linux manual page: crontab(5), a technical reference for recurring job schedules. Checked .
- Google SRE: Monitoring Distributed Systems, for signal and alert-design principles. Checked .
- Healthchecks.io: How to Monitor Cron Jobs (a documented implementation example, not a universal rule). Checked .