// guides

Get an alert when a cron job or n8n workflow silently stops running

Error alerts can't catch a job that never runs. Add a heartbeat (dead man's switch) to any cron job or n8n workflow: free options with Healthchecks.io, Uptime Kuma or 2 lines of cron.

Updated 2026-10-18 · about 10 minutes

Rather not set it up yourself? Describe your task in one sentence and we'll build and test it for you, free →

Steps

  1. Decide the longest acceptable gap

    Take the schedule and add a margin. A job that runs hourly gets 90 minutes, a nightly backup gets 26 hours. Too tight and you get false alarms on a slow run; too loose and you find out late.

  2. Make the job ping when it finishes

    At the very end of a successful run, call a URL. In cron: 0 * * * * /home/me/job.sh && curl -fsS -m 10 --retry 3 https://YOUR-PING-URL >/dev/null. The && means a failed run doesn't ping. In n8n: add an HTTP Request node (GET, the ping URL) as the last node of the workflow.

  3. Pick who watches for the ping

    Healthchecks.io has a free plan and is open source, so you can self-host it. Uptime Kuma (self-hosted) has a Push monitor type that gives you a ping URL and a heartbeat interval. Both alert you once when pings stop and once when they come back, by email, Discord, Telegram and more.

  4. No extra service? Use a file and cron

    Have the job run touch /var/tmp/job.ok when it succeeds, then add a second cron line that alerts when the file is missing or older than 90 minutes (see below). It only needs a Discord webhook.

  5. Test it by breaking it

    Pause the job or deactivate the workflow, wait past the gap, and check the alert really arrives. Then turn it back on and check you get the recovery message. An alert you never tested is a guess.

Why your error alerts miss this

An n8n error workflow, a try/except or a cron MAILTO all react to a run that fails. They stay quiet when nothing runs at all: the workflow got deactivated, n8n or Docker didn't come back after a reboot, the cron daemon stopped, the laptop was asleep, a trigger's credentials expired. A heartbeat flips the logic around. Silence is the alarm, so it catches every one of those cases. Use both: an error workflow for runs that break, a heartbeat for runs that never happen.

When the run succeeds but produces nothing

The sneakiest failure: the job runs on time, exits cleanly, and writes nothing. An API returned an empty list, a login silently expired, a filter matched zero rows, the backup is a 0-byte file. A plain heartbeat says all is well. The fix is to ping only when the run produced something, and to say so when it didn't.

#!/bin/sh
# job.sh: do the work, then report what it produced
rows=$(python3 /home/me/export.py | tee /var/tmp/export.csv | wc -l)
if [ "$rows" -gt 0 ]; then
  curl -fsS -m 10 --retry 3 --data-raw "rows=$rows" https://hc-ping.com/YOUR-UUID >/dev/null
else
  curl -fsS -m 10 --retry 3 --data-raw "ran but produced 0 rows" https://hc-ping.com/YOUR-UUID/fail >/dev/null
fi

Healthchecks.io treats /fail as an immediate failure, so you hear about an empty run right away instead of waiting for the gap to run out, and it stores the text you POST, so the dashboard shows how many rows each run wrote. If the export crashes before printing anything, that also lands on the /fail branch.

For backups, check the result instead of the job: alert unless there is a backup that is recent and not tiny.

# every 30 minutes: alert unless a backup newer than 26 hours and bigger than 1 MB exists
*/30 * * * * test -n "$(find /backups -name '*.tar.gz' -mmin -1560 -size +1M 2>/dev/null)" || /home/me/alert.sh

We tested both: three rows sent a success ping with rows=3; an empty run and a crashed run each sent one /fail; a fresh 2 MB backup passed, while a fresh 0-byte file plus a 2-day-old full one raised the alert.

In n8n this mostly comes for free if the heartbeat HTTP Request node sits after the node that produces your data: when a node outputs 0 items, the nodes after it don't run, the execution still shows as successful, and the missing ping triggers the alert. Two catches. Turn on Execute Once in the HTTP Request node's settings, or it pings once per item. And if a node has Always Output Data switched on, it passes one empty item along, so the ping fires anyway. To handle that, or to require a minimum, put a Code node (mode Run Once for All Items) just before the ping:

// Pass one item on only if the run produced real data; otherwise stop here (no ping)
const real = $input.all().filter(i => Object.keys(i.json).length > 0).length;
if (real < 1) return [];   // raise 1 to your minimum, e.g. 10 rows
return [{ json: { produced: real } }];

The 2-line cron version

# in job.sh, as the last line
touch /var/tmp/job.ok

# watchdog: every 15 minutes, alert if the job hasn't succeeded for 90 minutes
*/15 * * * * test -n "$(find /var/tmp/job.ok -mmin -90 2>/dev/null)" || /home/me/alert.sh
#!/bin/sh
# alert.sh: post one message to a Discord webhook
curl -fsS -m 10 -H "Content-Type: application/json" \
  -d '{"content":"job.sh has not succeeded for 90 minutes"}' \
  "https://discord.com/api/webhooks/XXX/YYY"

This repeats every 15 minutes until the job runs again, which is often what you want for something important. Run the watchdog on a different machine from the job if you also want to know when the whole server is down.

Watching n8n from inside n8n

You can build a watchdog workflow: a Schedule Trigger every 15 minutes, the n8n node set to Execution → Get Many filtered on the workflow and status success with limit 1, an IF that checks whether its startedAt is older than your gap, then a Discord or email node. It's handy for many workflows at once, but it dies with n8n. Keep one external heartbeat for n8n itself.

Or download one that's ready

Our free heartbeat watchdog does all of this: an n8n workflow where jobs call a ping URL when they finish, and a Python version that watches files, pings, n8n workflows' last successful run and URLs, alerting Discord or email once when a heartbeat goes missing and once when it's back. It also covers the empty run without extra scripting: give a file check a pattern and a min_size (the newest db-*.sql.gz must be over 1 MB), or have jobs call /ping/name?count=12 with a min_count, or /ping/name/fail when a run went wrong.

Skip the setup: free download

The Heartbeat watchdog agent does all of this. It's tested, MIT-licensed, and comes as an n8n workflow plus a Python script.

Get the free Heartbeat watchdog agent → Or have us build yours →

FAQ

Isn't an n8n error workflow enough?

No. It only fires when a production execution fails. If the workflow never starts (deactivated, n8n down, server rebooted), there's no failure and no alert.

Should the ping go at the start or the end?

At the end, after the real work succeeded. A ping at the start only proves the job started, not that it finished.

How do I know when n8n itself is down?

Use a watcher that runs somewhere else: Healthchecks.io, an Uptime Kuma instance on another machine, or the cron watchdog on a different server. A watchdog inside n8n can't report its own death.

My workflow succeeds but does nothing. How do I get alerted?

Ping only when the run produced output: count the rows or files at the end and call the heartbeat URL only if there are some (or call /fail on Healthchecks.io if there are none). In n8n, put the ping after the node that produces data so 0 items means no ping.

Will it spam me?

Healthchecks.io and Uptime Kuma send one alert when pings stop and one when they resume. The cron version repeats on every check until the job recovers, unless you add a small state file.

Related guides

New guides

Want one built for your task?

Describe it in one sentence. We build it, test it and email it to you, usually within 24h. Free while we're in beta.

We'll only email you about your agent and TaskToAgent.