Detect Cron Job Partial Failure: Verify All Steps Complete
Your cron job runs multiple steps, but some succeed while others fail. Learn how to detect partial failures and ensure all steps complete.
The Problem: Partial Failures
Multi-step cron jobs can partially fail:
- First step succeeds, second step fails, but script continues
- Some files process successfully, others fail silently
- Database backup succeeds, but file sync fails
- API calls succeed but data validation fails
- Script exits with code 0 even when steps fail
Without checking each step, you might think the job succeeded when it actually partially failed.
Solution: Verify Each Step
Check the result of each step explicitly. Don't rely on exit codes alone—verify that each step produced expected results.
Bash Example: Check Each Step
#!/bin/bashset -eFAILED_STEPS=()# Step 1: Backup databaseif ! pg_dump mydb > /backups/db.sql; then FAILED_STEPS+=("database_backup")fi# Step 2: Sync filesif ! rsync -avz /data/ user@server:/backup/; then FAILED_STEPS+=("file_sync")fi# Step 3: Send reportif ! ./send-report.sh; then FAILED_STEPS+=("send_report")fi# Single ping with step completion data in payload# In DeadManPing panel: set validation rule "failed_steps_count" == 0# Panel will automatically detect if any steps failedFAILED_STEPS_COUNT=${#FAILED_STEPS[@]}curl -X POST "https://deadmanping.com/api/ping/multi-step?failed_steps_count=$FAILED_STEPS_COUNT"Python Example: Track Step Results
import subprocessimport requestsimport sysfailed_steps = []# Step 1if subprocess.run(['pg_dump', 'mydb'], stdout=open('/backups/db.sql', 'w')).returncode != 0: failed_steps.append('database_backup')# Step 2if subprocess.run(['rsync', '-avz', '/data/', 'user@server:/backup/']).returncode != 0: failed_steps.append('file_sync')# Step 3if subprocess.run(['./send-report.sh']).returncode != 0: failed_steps.append('send_report')# Single ping with step completion data in payload# In DeadManPing panel: set validation rule "failed_steps_count" == 0# Panel will automatically detect if any steps failedfailed_steps_count = len(failed_steps)requests.post(f"https://deadmanping.com/api/ping/multi-step?failed_steps_count={failed_steps_count}")Monitoring Partial Failures
After adding step verification to your scripts, use a dead man switch to monitor whether all steps completed successfully. If any step fails and your script exits with error code, the ping never arrives, and you get an alert.
Include failed step names in your ping payload so you can identify which steps fail most often.
Working Examples
See complete, working code examples in our GitHub repository:
View Examples on GitHub →Start Detecting Partial Failures
DeadManPing monitors whether all steps complete successfully. Set up monitoring in 2 minutes, get alerts when jobs partially fail.
Start Monitoring FreeRelated Articles
Learn more about cron job monitoring and troubleshooting:
Cron Job Returns Success But Fails
How to detect when cron jobs return success exit code but actually fail.
Verify Cron Job Completed
How to verify that cron jobs completed successfully.
Verify Cron Output
How to verify cron job script output contains expected content.
Monitor Cron Jobs: One Curl Line, No Migration
Monitor cron jobs with one curl line. No SDK, no migration—get alerts when jobs fail.