You’ve added your cron job, the syntax looks right, but nothing happens. No output, no errors, just silence. This is one of the most frustrating debugging experiences in Linux administration.
Here’s how to systematically find and fix the problem.
Check If Cron Is Actually Running
First, verify the cron daemon is running:
| |
If cron isn’t running, start it:
| |
Verify Your Crontab Entry Exists
Check that your job is actually in the crontab:
| |
A common mistake: editing /etc/crontab directly instead of using crontab -e, or vice versa. They have different formats—/etc/crontab requires a username field:
| |
The PATH Problem
This is the #1 reason cron jobs fail. Cron runs with a minimal PATH, typically just /usr/bin:/bin. Commands that work in your shell won’t work in cron.
Bad:
| |
Good:
| |
Find the full path to any command with which:
| |
Alternatively, set PATH at the top of your crontab:
| |
Environment Variables Are Missing
Cron doesn’t load your .bashrc, .profile, or .bash_profile. Environment variables you rely on won’t exist.
Option 1: Source your profile in the cron command:
| |
Option 2: Define variables in the crontab:
| |
Option 3: Use a wrapper script that sets up the environment:
| |
Permission Issues
Your script must be executable:
| |
Check the shebang line is correct:
| |
If writing to files, ensure the cron user has write permission to the destination:
| |
Capture Output to Debug
Cron discards output by default. Redirect it to see what’s happening:
| |
The 2>&1 captures both stdout and stderr. Check the log after the job should have run:
| |
Also check the system mail—cron sends output there by default:
| |
Check System Logs
Cron logs when jobs run (but not their output):
| |
You should see entries like:
If you don’t see your job listed, it’s not being triggered—recheck your timing syntax.
Timing Syntax Mistakes
Use crontab.guru to verify your timing. Common mistakes:
| |
Working Directory Assumptions
Scripts often assume they’re running from a specific directory. Cron runs from the user’s home directory. Use absolute paths or cd first:
| |
Or in your script:
| |
Quick Diagnostic Checklist
Run through this list when your cron job isn’t working:
- Is crond running?
systemctl status cron - Is the job in crontab?
crontab -l - Using full paths?
which commandto find them - Script executable?
chmod +x script.sh - Capturing output? Add
>> /tmp/debug.log 2>&1 - Check cron logs for execution evidence
- Check mail for error output
- Test the command manually with the same user cron uses
Nine times out of ten, it’s the PATH or a missing environment variable. When in doubt, use absolute paths for everything and explicitly set any environment your script needs.