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 DomainWarn extension creates the heartbeat for the scheduled tasks of WordPress and Shopware itself; if it stays away, the finding names the typical causes of the platform – WP-Cron without a cron job, stuck scheduled tasks, the admin worker, the website being unreachable or the extension no longer reporting at all – and puts the most likely one first based on what the extension last reported, with a ready-made cron job line.

If a job runs very often, such as WP-Cron every 5 minutes, the setting “Alert after” bridges short gaps: the heartbeat only alerts once 2, 3, 5 or 10 runs in a row have stayed away; the grace period applies on top, a reported failure counts immediately. Below each heartbeat a strip shows the last 30 days, one bar per day: green on time, yellow late, red missed or failed, along with the share of runs on time. Missed runs count on the day they were due.

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