Your cron job runs perfectly in testing but fails silently in production. Cron debugging is frustrating because errors are silent by default.
This guide covers the 10 most common cron failures and how to debug them systematically.
Cron Syntax Refresher#
5-Field Format (Standard Linux):
* * * * * command
│ │ │ │ │
│ │ │ │ └─ Day of week (0-7, 0 and 7 = Sunday)
│ │ │ └─── Month (1-12)
│ │ └───── Day of month (1-31)
│ └─────── Hour (0-23)
└────────── Minute (0-59)
6-Field Format (some systems):
* * * * * * command ← Adds seconds field at start
Special Characters:
*— Any value,— List (1,3,5)-— Range (1-5)/— Step (*/ 5 = every 5)
Problem #1: Timezone Issues#
The Silent Killer: Your cron runs in server time, not your local time.
Symptom: Job scheduled for "9 AM" runs at 2 PM your time.
Diagnosis:
# Check server timezone
date
timedatectl # on systemd systems
Solution:
- Set timezone in crontab:
TZ=America/New_York - Or use UTC and calculate offset
- Document timezone in comments
Problem #2: Syntax Errors#
❌ Wrong: */5 * * * * vs 0/5 * * * *
Both mean "every 5 minutes" but */5 is preferred.
❌ Wrong: 0 0 31 2 * (Feb 31st doesn't exist!)
❌ Wrong: * * * * 1-5 (Days 1-5 of week, not Monday-Friday!)
✅ Correct for weekdays: 0 9 * * 1-5 (9 AM Monday-Friday)
Testing: Use Cron Expression Generator to validate syntax.
Problem #3: Permission Issues#
The Problem: Cron runs with minimal permissions. Your script can't access files.
Diagnosis:
# Check which user cron runs as
* * * * * whoami > /tmp/cronuser.txt
# Check file permissions
ls -la /path/to/script.sh
Solutions:
- Make script executable:
chmod +x script.sh - Use absolute paths:
/home/user/script.sh - Check file ownership:
chown user:user script.sh
Problem #4: PATH Problems#
The Problem: Cron has a minimal PATH. Commands that work in your shell fail in cron.
❌ This fails:
* * * * * node /path/to/app.js
✅ This works:
PATH=/usr/local/bin:/usr/bin:/bin
* * * * * /usr/local/bin/node /path/to/app.js
Alternative: Use absolute paths for all commands.
Problem #5: No Logging#
The Problem: Errors are silent. You don't know why the job failed.
✅ Always log output:
* * * * * /path/to/script.sh >> /var/log/myjob.log 2>&1
2>&1 captures both stdout and stderr.
Email errors:
MAILTO=admin@example.com
* * * * * /path/to/script.sh
Cron emails output if MAILTO is set.
Step-by-Step Debugging#
When a cron job doesn't run:
- Verify cron daemon is running:
systemctl status cron - Check cron logs:
grep CRON /var/log/syslog - Test expression: Use online cron calculator
- Run manually: Execute the exact command from crontab
- Check permissions: Can the user access all files?
- Add logging: Redirect output to file
- Test timezone: Verify server time matches expectation
Frequently Asked Questions
Why is my cron job not running?▼
How do I test a cron expression without waiting?▼
What does "0/5 * * * *" mean?▼
How do I debug silent cron failures?▼
Why does my cron script work manually but not in cron?▼
Generate Cron Expressions
Use our cron expression generator to create and test valid cron schedules. Visual interface with real-time next run previews.