Linux Cron Failure Troubleshooting Checklist
Cron jobs often fail silently because their environment is different from an interactive shell. Paths, permissions, working directory, output handling and environment variables can all break scheduled tasks.
Core principle
A cron job is not just a command. It is a command running at a time, as a user, with a limited environment and usually without a visible terminal.
Checklist
- Identify which user owns the cron job.
- List the crontab.
- Check cron syntax.
- Use absolute paths for commands and files.
- Redirect output and errors to a log file.
- Check permissions of scripts.
- Check environment variables.
- Check cron logs.
- Run the command manually as the cron user.
- Document schedule and expected result.
Reusable lesson
This applies to backups, SSL renewals, imports, cache cleanup, monitoring scripts, AI automation jobs and maintenance tasks.
When to Use This Checklist
Use this checklist when a scheduled task does not run, runs inconsistently or works manually but fails in cron.
Required Tools
SSH access, crontab, cron logs, script path, target user, log file path
Before You Start
Do not assume cron has the same environment as your terminal session. Use absolute paths and explicit logging.
Structured Checklist Steps
- Identify cron user.
- List crontab.
- Check syntax.
- Use absolute paths.
- Redirect output.
- Check script permissions.
- Check environment.
- Read cron logs.
- Test as cron user.
- Document schedule.
Verification Steps
- Cron job runs at expected time.
- Output or error log is created.
- Script permissions are correct.
- Manual test as cron user works.
- Schedule is documented.
Rollback Plan
If a cron change creates errors or load, comment out the cron line, keep the logs and test the command manually before re-enabling.
Common Mistakes
- No error logging.
- Relative paths.
- Wrong user context.
- Missing environment variables.
- Heavy jobs overlapping.
Related Commands
crontab -l
sudo crontab -l
which php
chmod +x /path/to/script.sh
sudo -u www-data /path/to/script.sh
grep CRON /var/log/syslog | tail -n 50
grep CRON /var/log/cron | tail -n 50