Working code examples for backup dead man switch monitoring and cron job monitoring with DeadManPing.
This repository contains real-world examples in multiple languages showing how to:
- Detect empty backup files (zero bytes)
- Detect when backups don't run (dead man switch)
- Verify backup file sizes (payload validation)
- Detect silent cron failures
- Check exit codes and status
- Handle edge cases
- Monitor job execution
- Sign up for DeadManPing (free account)
- Create a monitor and get your ping URL
- Copy an example script below
- Replace
YOUR_MONITOR_IDwith your actual monitor ID - Add the script to your cron job
| Problem | Solution | Examples |
|---|---|---|
| Backup Didn't Run | Dead man switch detects missing backups | Bash | Python | Node.js |
| Detect Empty Backup File | Check if backup file is zero bytes | Bash | Python | Node.js |
| Detect Empty Backup File Cron | Check backup file size after creation | Bash | Python | Node.js |
| Backup File Zero Bytes | Detect empty backup files | Bash | Python | Node.js |
| Verify Backup File Size | Check backup file size ranges | Bash | Python | Node.js |
| Detect Backup File Missing | Verify backup file exists | Bash | Python | Node.js |
- Bash Examples - Shell scripts for Linux/Unix systems
- Python Examples - Python scripts with error handling
- Node.js Examples - JavaScript/Node.js examples
- Cron Patterns - Example crontab entries
- Edge Cases - Advanced scenarios and rare cases
Each example links to detailed documentation on deadmanping.com:
- Backup Dead Man Switch - Complete guide on backup dead man switch monitoring
- Backup Didn't Run - How to Detect - Detect when backup jobs don't run
- Detect Empty Backup File - How to detect zero-byte backup files
- Backup Monitoring Without Infrastructure - Monitor backups without Kubernetes/Prometheus
- Dead Man Switch for Backups - Dead man switch monitoring for backup jobs
- Backup Monitoring Service - Backup monitoring that doesn't touch your execution
- Monitor Cron Jobs - Monitor cron jobs without migration
- Cron Job Failed - Detect and fix cron job failures
DeadManPing uses a dead man switch pattern for backup monitoring:
- Your cron job runs your backup script
- Your backup script performs its work (rsync, database dump, etc.)
- Your backup script sends a ping to DeadManPing when done (with backup data like file size)
- If the ping doesn't arrive, you get an alert - backup didn't run or failed
- DeadManPing validates backup data (file size, status) and alerts if backup is empty or incorrect
Important: The ping must be inside your backup script, not in the cron line, because only in the script do you have access to variables from execution results (e.g., backup file size, success status).
Example: If your backup script creates an empty file (0 bytes), DeadManPing detects this by validating the file size in the ping payload. If your backup script doesn't run at all, the ping never arrives, and DeadManPing alerts you.
- Sign up at deadmanping.com
- Create a monitor
- Copy your unique ping URL (format:
https://deadmanping.com/api/ping/YOUR_MONITOR_ID) - Replace
YOUR_MONITOR_IDin the examples with your actual monitor ID
Found a bug or have a better example? Open an issue or submit a pull request!