Skip to content
Blue Radar

Monitor a cron job

Get an email when a scheduled job stops checking in.

A heartbeat expects your job to call its URL on a schedule. If no call arrives in time, the heartbeat goes down and the team gets an email.

Create it

Monitoring, Create monitor, Heartbeat monitor.

Set the schedule

Expect a ping every: how often the job runs, from 1 minute to 30 days. Grace period: extra time to wait after a ping is due, from 1 minute to 30 days.

Copy the URL

The Setup tab shows the heartbeat URL once. Copy it now:

text
https://api.blueradar.net/ping/YOUR_TOKEN

Call it from your job

Call the URL with GET, POST or HEAD when the job finishes.

0 3 * * * /usr/local/bin/backup.sh && curl -fsS -m 10 --retry 3 https://api.blueradar.net/ping/YOUR_TOKEN
./backup.sh
curl -fsS -m 10 --retry 3 https://api.blueradar.net/ping/YOUR_TOKEN/$?
Schedule::command('backup:run')
    ->daily()
    ->thenPing('https://api.blueradar.net/ping/YOUR_TOKEN');
import urllib.request

urllib.request.urlopen("https://api.blueradar.net/ping/YOUR_TOKEN", timeout=10)

Report start and failure

URL Means
/ping/YOUR_TOKEN The job finished
/ping/YOUR_TOKEN/start The job started
/ping/YOUR_TOKEN/fail The job failed. The heartbeat goes down at once
/ping/YOUR_TOKEN/0 to /255 The job's exit code. 0 counts as finished, anything else as failed

Responses

A ping answers 200 OK. A heartbeat accepts up to 120 pings a minute; past that it answers 429 with Retry-After. A 503 means try again in a few seconds.

A plain GET /ping/YOUR_TOKEN always answers 200 ok, even for a token that does not exist, so check the monitor in Blue Radar after you set it up.