Keep an eye on a backup script, cron job or scheduled task by having it check in with InfraNest — this is for anyone who wants to know the moment a routine job silently stops running.
Overview
- A heartbeat monitor works in reverse to most checks: instead of InfraNest reaching out to your service, your job calls in to InfraNest each time it finishes.
- If the call-in doesn't arrive on time, InfraNest raises an alert.
- This is the best way to catch a job that has quietly stopped running, rather than one that's just slow to respond.
Set one up
- Go to Monitors and select add a monitor.
- Choose Heartbeat / Cron monitor as the type.
- Give it a name you'll recognise in an alert — "Nightly database backup" beats "job 1".
- Set the check interval to how often the job is supposed to run.
- Set a grace period — extra time allowed before the job is called late. A backup that usually takes four minutes but occasionally takes eight needs a grace period comfortably longer than that overrun.
- Select create monitor.
You don't enter a URL for this type — InfraNest creates one for you when you save.
Make your job check in
- Open the monitor to see its ping URL, plus a ready-to-paste one-liner.
- Add that line to the end of your script or cron job, so it only runs when the job actually succeeded:
0 3 * * * /usr/local/bin/backup.sh && curl -fsS -m 10 --retry 3 https://your-infranest-url/api/heartbeat/your-uuid
- Keep the
&&in place — it means the check-in only happens if the backup itself exited successfully. A failed job then stays silent, and silence is what raises the alert. - Use the Copy button rather than retyping the URL — the identifier in it is unique to this monitor.
What happens next
- Every check-in marks the monitor Active and records the time as its last ping.
- A brand-new monitor stays pending until its first window has passed, so you have time to wire the check-in up without being alerted about it.
- If nothing arrives within the interval plus the grace period, the monitor goes Inactive and opens an incident, so your usual alert destinations fire.
- The next check-in resolves the incident and alerts you that it's back — you don't have to close it by hand.
NotePausing a heartbeat monitor is safe: the ping URL keeps answering normally, so a job that's still calling it won't start reporting failures. InfraNest simply stops watching until you resume.
TipTreat the ping URL as a secret. Anyone who has it can report your job as healthy — which would hide a real failure.
Troubleshooting
- No ping received yet on the monitor means InfraNest hasn't heard from the job at all. Run the curl line by hand from the same machine: if that turns the monitor Active, the problem is in your script, not here.
- If the machine can't reach the internet outbound, the check-in can't arrive — allow outbound HTTPS to InfraNest.
- A monitor that alerts every night at the same time usually has a grace period shorter than the job's real worst-case runtime.
Was this article helpful?