Guides

Cron Expression Debugging: 10 Common Failures & Solutions [Save Hours]

9 min read
January 24, 2026
cron expression errors, debug cron job, cron syntax

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:

  1. Set timezone in crontab: TZ=America/New_York
  2. Or use UTC and calculate offset
  3. 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:

  1. Verify cron daemon is running: systemctl status cron
  2. Check cron logs: grep CRON /var/log/syslog
  3. Test expression: Use online cron calculator
  4. Run manually: Execute the exact command from crontab
  5. Check permissions: Can the user access all files?
  6. Add logging: Redirect output to file
  7. Test timezone: Verify server time matches expectation

Frequently Asked Questions

Why is my cron job not running?
Common causes: wrong syntax, timezone mismatch, permission issues, incorrect PATH, or the cron daemon is not running. Check /var/log/syslog for cron execution logs.
How do I test a cron expression without waiting?
Use online cron calculators to see when the job will run next. For immediate testing, temporarily change the expression to run every minute (* * * * *), then revert after testing.
What does "0/5 * * * *" mean?
It means "every 5 minutes starting at minute 0", which is functionally the same as */5 (every 5 minutes). Both run at :00, :05, :10, :15, etc.
How do I debug silent cron failures?
Add logging: * * * * * /script.sh >> /tmp/cron.log 2>&1. This captures all output and errors. Also check system logs with: grep CRON /var/log/syslog
Why does my cron script work manually but not in cron?
Cron has a minimal environment (limited PATH, no shell variables). Use absolute paths for all commands and files, or set PATH explicitly in your crontab.

Generate Cron Expressions

Use our cron expression generator to create and test valid cron schedules. Visual interface with real-time next run previews.

Try Cron Generator