Cron Job Exit Status Check: Verify Job Completion
Your cron job completes, but did it exit with the correct status? Learn how to check exit status and verify jobs completed successfully.
Understanding Exit Status
Exit status indicates job completion:
- Exit 0 - Success
- Exit 1 - General error
- Exit 2 - Misuse of command
- Any non-zero - Failure
Always check exit status after running commands to verify they completed successfully.
How to Check Exit Status
Check exit status after each command. The check must be inside your script, not in the cron line.
Bash Example: Check Exit Status
#!/bin/bashset -e # Exit on error# Run command./backup.shEXIT_STATUS=$?# Single ping with exit status in payload# In DeadManPing panel: set validation rule "exit_status" == 0# Panel will automatically detect if exit status is non-zero and alertcurl -X POST "https://deadmanping.com/api/ping/backup-daily?exit_status=$EXIT_STATUS"Python Example: Check Return Code
import subprocessimport requestsimport sysresult = subprocess.run(['./backup.sh'])# Single ping with exit status in payload# In DeadManPing panel: set validation rule "exit_status" == 0# Panel will automatically detect if exit status is non-zero and alertrequests.post(f"https://deadmanping.com/api/ping/backup-daily?exit_status={result.returncode}")Monitoring Exit Status
After adding exit status checks to your scripts, use a dead man switch to monitor whether checks completed successfully. If your script detects a non-zero exit status and exits with error, the ping never arrives, and you get an alert.
Working Examples
See complete, working code examples in our GitHub repository:
View Examples on GitHub →Start Checking Exit Status
DeadManPing monitors whether your exit status checks complete. Set up monitoring in 2 minutes, get alerts when jobs exit with non-zero status.
Start Monitoring FreeRelated Articles
Learn more about cron job monitoring and troubleshooting:
Cron Job Exit Code Not Zero
How to detect when cron jobs exit with non-zero exit codes.
Detect Cron Job Wrong Exit Code
How to detect when cron jobs return wrong exit codes.
Verify Cron Job Completed
How to verify that cron jobs completed successfully.
Monitor Cron Jobs: One Curl Line, No Migration
Monitor cron jobs with one curl line. No SDK, no migration—get alerts when jobs fail.