Skip to content
← All recipes

Monitor cron jobs with a heartbeat

Add a curl to your crontab line so missed, failed and empty cron runs alert you.

Signed in? Open any watch in your dashboard to see this recipe with your real ping URL filled in.

The classic dead man's switch: ping after a successful run. If the server is down, cron stops, or the script fails, the ping never arrives.

One-liner

bash
# m h dom mon dow   command
15 9 * * 1-5  /opt/jobs/digest.sh && curl -fsS -m 10 --retry 3 https://diditrun.app/p/YOUR-TOKEN > /dev/null

Create the watch with the same expression (15 9 * * 1-5) and the server's timezone.

Report start, failure and output

bash
#!/usr/bin/env bash
URL="https://diditrun.app/p/YOUR-TOKEN"
curl -fsS -m 10 --retry 3 "$URL/start" > /dev/null
if out=$(/opt/jobs/digest.sh 2>&1); then
  curl -fsS -m 10 --retry 3 -X POST --data-binary "$out" "$URL" > /dev/null
else
  curl -fsS -m 10 --retry 3 -X POST --data-binary "$out" "$URL/fail" > /dev/null
fi

Send an item count

bash
count=$(wc -l < /var/data/today.csv)
curl -fsS -m 10 --retry 3 "$URL?items=$count"

Set Minimum item count on the watch and an empty export raises an alert.

Windows Task Scheduler / PowerShell

powershell
Invoke-RestMethod -Method Post -Uri "https://diditrun.app/p/YOUR-TOKEN" -Body "done"

Set it up free

3 watches free on Did It Run?. No credit card.

Create your first watch