Skip to content
Documentation · Heartbeat monitors

DocsMonitoring

Heartbeat (cron) monitors

Monitor cron jobs, backups, queues and workers with heartbeat URLs — setup, grace period and examples for crontab, curl, wget, PowerShell and systemd timers.

On this page

Some things can't be checked from the outside: a nightly backup, a queue worker, a script on a server behind a firewall. A heartbeat monitor turns it around — your job calls a unique URL every time it runs, and we alert you when a call doesn't arrive in time.

How it works#

  1. Create a monitor of type Heartbeat and set the interval to how often the job runs (for example 1 hour for an hourly job, 24 hours for a nightly one).
  2. Set the grace period (graceSeconds, 0–86,400 seconds, default 60): how late a call may be before it counts as missed. Give jobs with a variable run time more grace.
  3. Save. The monitor shows its heartbeat URL:
text
https://api.isituprightnow.com/api/v1/heartbeat/<token>
  1. Call this URL at the end of every successful run, with GET, POST or HEAD. It answers 200 ok.

If no call arrives within interval + grace after the previous one, the monitor is confirmed down, an incident opens and your alert rules apply. The next call marks it up again and resolves the incident.

Responses#

Response Meaning
200 ok The ping was recorded.
200 ok (paused) The monitor is paused; nothing is recorded.
404 Unknown token (the monitor was deleted, or the URL is wrong).
429 More than 60 calls per minute for this monitor.

Calls are cheap and the endpoint accepts any origin, so you can also call it from serverless functions or CI pipelines.

Examples#

Replace <token> with your monitor's token, or copy the full URL from the monitor page.

crontab + curl#

Ping only when the job succeeded (&&), with retries and a timeout so a network blip doesn't fail the job:

bash
# m h dom mon dow  command
30 2 * * * /usr/local/bin/backup.sh && curl -fsS -m 10 --retry 3 -o /dev/null https://api.isituprightnow.com/api/v1/heartbeat/<token>

wget#

bash
/usr/local/bin/backup.sh && wget -q -T 10 -t 3 -O /dev/null https://api.isituprightnow.com/api/v1/heartbeat/<token>

Inside a shell script#

bash
#!/usr/bin/env bash
set -euo pipefail

pg_dump --format=custom mydb > /backups/mydb.dump

# Reached only if every command above succeeded.
curl -fsS -m 10 --retry 3 -o /dev/null "https://api.isituprightnow.com/api/v1/heartbeat/<token>"

PowerShell (Windows Task Scheduler)#

powershell
& "C:\jobs\export.ps1"
if ($LASTEXITCODE -eq 0) {
    Invoke-RestMethod -Uri "https://api.isituprightnow.com/api/v1/heartbeat/<token>" -Method Post -TimeoutSec 10
}

systemd timer#

Ping from a separate unit that runs only when the job unit succeeded:

ini
# /etc/systemd/system/backup.service
[Unit]
Description=Nightly backup
OnSuccess=backup-heartbeat.service

[Service]
Type=oneshot
ExecStart=/usr/local/bin/backup.sh
ini
# /etc/systemd/system/backup-heartbeat.service
[Unit]
Description=Report the backup to isituprightnow

[Service]
Type=oneshot
ExecStart=/usr/bin/curl -fsS -m 10 --retry 3 -o /dev/null https://api.isituprightnow.com/api/v1/heartbeat/<token>
ini
# /etc/systemd/system/backup.timer
[Unit]
Description=Run the backup every night

[Timer]
OnCalendar=*-*-* 02:30:00
Persistent=true

[Install]
WantedBy=timers.target

Enable it with systemctl enable --now backup.timer. (OnSuccess= needs systemd 249 or later; on older systems add ExecStartPost= with the curl command to backup.service.)

Kubernetes CronJob#

yaml
apiVersion: batch/v1
kind: CronJob
metadata:
  name: nightly-report
spec:
  schedule: "0 3 * * *"
  jobTemplate:
    spec:
      template:
        spec:
          restartPolicy: Never
          containers:
            - name: report
              image: registry.example.com/report:latest
              command: ["/bin/sh", "-c"]
              args:
                - ./run-report && wget -q -T 10 -O /dev/null https://api.isituprightnow.com/api/v1/heartbeat/<token>

Tips#

  • Ping at the end, not the start. A ping at the start only proves the job began.
  • Long jobs: set the interval to the schedule and the grace period to the longest normal run time.
  • Irregular jobs (for example a queue worker): ping from the worker's main loop at most once a minute and use an interval of a few minutes.
  • Pausing: pause the monitor before you disable the job, so the missing pings don't open an incident.

Didn't find what you were looking for? Contact us.