0 2 * * * /usr/local/bin/backup.sh
0 2 * * * /usr/local/bin/backup.sh
0 2 * * * /usr/local/bin/backup.sh
https://example.com/heartbeat/backup-job
https://example.com/heartbeat/backup-job
https://example.com/heartbeat/backup-job
0 2 * * * /usr/local/bin/backup.sh && curl -fsS https://example.com/heartbeat/backup-job
0 2 * * * /usr/local/bin/backup.sh && curl -fsS https://example.com/heartbeat/backup-job
0 2 * * * /usr/local/bin/backup.sh && curl -fsS https://example.com/heartbeat/backup-job
0 2 * * * /usr/local/bin/backup.sh \ && curl -fsS https://example.com/heartbeat/backup-job/success \ || curl -fsS https://example.com/heartbeat/backup-job/failure
0 2 * * * /usr/local/bin/backup.sh \ && curl -fsS https://example.com/heartbeat/backup-job/success \ || curl -fsS https://example.com/heartbeat/backup-job/failure
0 2 * * * /usr/local/bin/backup.sh \ && curl -fsS https://example.com/heartbeat/backup-job/success \ || curl -fsS https://example.com/heartbeat/backup-job/failure
backup.sh ; curl ...
backup.sh ; curl ...
backup.sh ; curl ...
backup.sh && curl ...
backup.sh && curl ...
backup.sh && curl ... - You manually check logs
- A user reports that something is broken
- Data starts looking wrong - Track execution success
- Retry failed jobs
- Notify you on failure
- Verify that the job actually completed - The script exits early with no useful error output
- Dependencies change, such as an API, database, or file system
- Network issues break external calls
- Environment variables differ from your interactive shell - Arrives on time -> the job is healthy
- Is missing or late -> something is wrong - Runs your script
- Sends the heartbeat only if the script succeeds because of &&
- Gives your monitoring system a reliable signal that the job completed - Expect a signal every day around 2 AM
- Alert you if it does not arrive
- Optionally track failures too - Good for debugging
- Works with existing systems - Reactive, not proactive
- Easy to miss issues - Works well for APIs - Not ideal for background jobs
- Does not confirm job completion - More control
- Built-in retries - Overkill for simple cron jobs - Fully customizable - Time-consuming
- Reinventing the wheel - It depends on system configuration
- It is often unreliable or ignored
- It does not detect silent failures - Add a request at the end of the job
- Track expected intervals
- Alert on missing signals - Hourly jobs -> expect hourly signals
- Daily jobs -> expect one signal per day - Add a heartbeat signal to every job
- Track when it should arrive
- Alert when it does not