Heartbeat (monitoring for cron jobs and backups)

A heartbeat is a regular check-in that a cron job, backup or import sends to a monitor after every run, so that a missing run gets noticed.

How it works

Classic monitoring asks from the outside whether something responds. A heartbeat flips that around: the job itself calls a secret ping URL once its work is done. If that call stays away longer than expected, the job did not run, is stuck or quit early, which is why this pattern is also called a dead man’s switch.

Every heartbeat has a period (how often the job runs, daily for instance) and a grace time (how much delay is still normal). A backup that starts at 2 in the morning and sometimes takes an hour gets a 24-hour period and a grace time of one to two hours.

Many jobs can also report a failure actively by calling a separate URL when something goes wrong. That lets the monitor tell “did not run” apart from “ran but failed”.

Why it matters

Failed background jobs go unnoticed because nothing visibly breaks until you need them. The nightly backup has not run in weeks, the product import is stuck, newsletters never go out or a certificate is not renewed.

In WordPress and Shopware, updates, scheduled posts, indexing and outgoing mail all depend on scheduled tasks. When WP-Cron or Shopware’s scheduled tasks stall, the site keeps working on the outside while everything piles up behind the scenes.

How to prevent it

  1. Set up a separate heartbeat for every job that matters: backup, import, export, mailing, certificate renewal.
  2. Call the ping URL only at the end of the job and only on success, and the failure URL otherwise, for example with curl -fsS --retry 3 in a shell script.
  3. Choose period and grace time based on how long the job really takes, so you get neither false alarms nor late ones.
  4. In WordPress, set DISABLE_WP_CRON and add a real cron job at the host instead of relying on page views.
  5. After every server or hosting migration, check that the crontab moved along with everything else.

How DomainWarn detects it

The Heartbeat check evaluates every five minutes when the last ping arrived. If it stays away longer than period plus grace time, that is critical and opens the incident “Heartbeat missed (job did not run)”; the next ping resolves it right away. A call to …/fail reports a failure and opens “Heartbeat reports failure”. A new heartbeat that has never checked in gets a warning once its first deadline passes. For very frequent jobs you can set it to alert only after 2, 3, 5 or 10 missed runs in a row.

The DomainWarn extensions for WordPress and Shopware create the heartbeat for their scheduled tasks automatically. If it goes missing, the finding names the likely cause, such as WP-Cron without a real cron job, stuck scheduled tasks, an active admin worker or a website that is currently unreachable.

DomainWarn checks this for all your domains on a schedule and alerts you when something is missing or changes.

Monitor this domain continuously14-day free trial, no credit card.