How to find out why a cron job fails silently
By TechCompare · Updated · How we check
Never deploy a cron job without output capture. At minimum, redirect to a log file. For production, add structured logging with timestamps, exit codes, and runtime.
Cron's default failure mode is silence. If a job fails, cron sends the output to the user's local mail spool, which on most modern systems goes unread because nothing is configured to deliver it. A job can fail for weeks without anyone noticing. Fixing this means redirecting output somewhere you'll actually see it.
How this is calculated
Three debugging strategies work:
- Redirect STDOUT and STDERR to a log file: 0 * * * * /path/to/script >> /var/log/myjob.log 2>&1.
- Email the output by setting MAILTO=you@example.com in your crontab. MAILTO does not send a message for a successful run that produces no output.
- Wrap the command in a script that logs the start time, exit code, and runtime duration.
The most common silent failure cause is missing environment: cron runs with a minimal PATH (typically /usr/bin:/bin) and no shell profile loaded. Always use absolute paths to executables in cron commands, or set PATH explicitly in the crontab.
Verdict
Capture output on every cron job. Redirect both streams to a log file ('>> /var/log/job.log 2>&1'), set MAILTO at the top of the crontab for email alerts, and remember cron typically runs with PATH=/usr/bin:/bin and no shell profile loaded. Hard-code absolute paths or set PATH explicitly.
More Cron scenarios
Related guides
Frequently asked questions
Why does my cron job fail silently with no error output?
Why does my script work in the shell but fail under cron?
How do I get cron to email me when a job fails?
Related tools
Unix Timestamp
Convert between Unix timestamps and human-readable dates.
Use toolCHMOD Configurator
Calculate Linux file permissions using checkboxes or octal numbers, then view the matching symbolic notation.
Use toolText Encoding Converter
Convert text to Base64, binary, hex, URL encoding and HTML entities, and back again.
Use tool