You added a cron job. You’re sure the syntax is right. But nothing happens. No output, no errors, just silence. Here’s how to figure out what’s wrong.
Check If Cron Is Actually Running
First, verify the cron daemon is alive:
| |
If it’s not running, start it:
| |
Verify Your Crontab Is Loaded
Check that your cron job actually exists:
| |
If you edited /etc/crontab or files in /etc/cron.d/, those have a different format (they include a username field):
| |
Mixing these formats is a common cause of silent failures.
The PATH Problem
This is the #1 reason cron jobs fail. Your interactive shell has a rich PATH with /usr/local/bin, ~/.local/bin, etc. Cron’s PATH is minimal:
| |
Your script works when you run it manually but fails in cron because it can’t find node, python3, docker, or whatever command you’re using.
Fix 1: Use absolute paths
| |
Find the absolute path with which:
| |
Fix 2: Set PATH in crontab
| |
Environment Variables Are Missing
Cron runs with almost no environment. Variables you set in .bashrc, .profile, or .env don’t exist.
Fix: Source your environment or set variables explicitly
| |
Check the Cron Logs
Cron logs where it runs jobs. Find out what’s happening:
| |
You’ll see entries like:
If you don’t see your job listed at all, the crontab isn’t being read or the schedule hasn’t triggered yet.
Capture Output to Debug
By default, cron emails output to the local user. If you don’t have local mail configured, it vanishes. Redirect to a file:
| |
The 2>&1 captures both stdout and stderr. Now check cron.log to see what’s actually happening.
Permission Problems
Your script must be executable:
| |
If your script writes to files, cron runs as your user but might have different permissions context. Test by running:
| |
The Timing Gotcha
Cron uses the system timezone, not necessarily yours:
| |
If your server is UTC and you’re in EST, a job scheduled for 0 9 * * * runs at 9 AM UTC (4 AM EST in winter, 5 AM EST in summer).
Also, */5 means “every 5 minutes” but starts from minute 0 — so it runs at :00, :05, :10, etc., not 5 minutes from when you saved the crontab.
The Script Works Manually But Not in Cron
If you’ve checked everything above and your script still only works interactively, create a wrapper that mimics cron’s environment:
| |
Run this wrapper. If it fails the same way cron fails, you’ve reproduced the issue and can debug from there.
Quick Debugging Checklist
- Is cron running? (
systemctl status cron) - Is the job in crontab? (
crontab -l) - Is the schedule correct? (Use crontab.guru to verify)
- Are you using absolute paths for commands?
- Are environment variables set?
- Is the script executable?
- What do the logs say? (
grep CRON /var/log/syslog) - What does redirected output show?
Nine times out of ten, it’s the PATH. Start there.