Heartbeats

Heartbeats watch that cron jobs, backups and imports actually run: one ping URL per job, period and grace time, and failure reports via …/fail.

On this page

Heartbeats for cron jobs and backups

A heartbeat monitors that a job runs at all: nightly backup, shop import, newsletter dispatch, certificate renewal. You create it in the domain settings (name, expected period, grace) and add the call to its ping address to the end of the job. If the call stays away longer than period plus grace, DomainWarn opens the incident heartbeat_missed; the next ping resolves it immediately. Calling …/fail reports a failure (heartbeat_failed).

The address needs no login, the token in the address is the proof; GET and POST are equivalent. For cron, curl -fsS --retry 3 makes sure short network hiccups do not swallow the ping.

backup-nightly.sh
#!/bin/sh
# backup, then report the heartbeat – on error …/fail
if /usr/local/bin/backup.sh; then
  curl -fsS --retry 3 https://api.domainwarn.com/api/v1/heartbeats/<TOKEN>
else
  curl -fsS https://api.domainwarn.com/api/v1/heartbeats/<TOKEN>/fail
fi