What is a dead man's switch monitor? (And when to use one)

A dead man's switch is a monitoring technique where your system pings a service on a schedule. If the ping is missing, an alert is fired. Learn how to use it for backups and workers.

If you've ever scheduled a backup script or a data pipeline, you've probably wondered: how do I know if it actually ran?

Most developers start by adding email or Slack alerts at the end of their script. If the script fails, it sends a message. Simple, right?

But what happens if the server crashes before the script even starts? What if the cron daemon dies? What if there's a typo in the crontab?

Your script fails silently. No errors, no emails, just a missing backup when you need it most.

This is where a dead man's switch (also known as heartbeat monitoring) comes in.

How it works

Instead of the monitoring service calling your system (like a traditional uptime monitor), your system calls the monitoring service.

  1. You create a monitor in a tool like CronSpark.
  2. It gives you a unique URL.
  3. You add a simple curl request to the very end of your script to ping that URL.
  4. You tell CronSpark: "Expect a ping on this URL every 24 hours."

If CronSpark doesn't receive that ping within the 24-hour window, it assumes the job failed (or never started) and triggers an alert.

When to use a dead man's switch

You should use a dead man's switch for any background task where a silent failure is dangerous:

Setting it up in bash

It's incredibly simple to add. Just append a curl command to your existing script:

#!/bin/bash

# Your backup logic here
pg_dump mydb > backup.sql

# If the backup succeeds, ping the dead man's switch
if [ $? -eq 0 ]; then
  curl -m 10 --retry 3 https://api.cronspark.com/ping/YOUR_UNIQUE_ID
fi

With this pattern, if the pg_dump fails, or if the server is offline, the ping never happens. The dead man's switch triggers, and you get a Slack message telling you to check your backups before it's too late.

Stop relying on your scripts to report their own failures. Use a dead man's switch and sleep better at night.