ConfigClarity

Free browser-based DevOps audit tools โ€” no signup, nothing leaves your browser

Cron job not running

Silent failure โ€” no error, no output, job just doesn't run

Cron silently discards output by default. If your script errors, you'll never know unless you explicitly redirect output to a log file.

Step 1 โ€” Verify the cron daemon is running

# Check cron service status
systemctl status cron        # Ubuntu/Debian
systemctl status crond       # CentOS/RHEL/Fedora

# If not running:
sudo systemctl start cron
sudo systemctl enable cron

Step 2 โ€” Add output redirection to catch errors

โŒ Silent โ€” errors go nowhere
*/15 * * * * /usr/local/bin/backup.sh
โœ… Logs all output and errors
*/15 * * * * /usr/local/bin/backup.sh >> /var/log/backup.log 2>&1

Step 3 โ€” Fix PATH issues (most common cause)

Cron runs with a minimal PATH: /usr/bin:/bin. Commands that work in your shell may not be found by cron.

โœ… Set PATH at the top of your crontab
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# Or use full absolute paths in each command:
*/15 * * * * /usr/local/bin/python3 /home/user/script.py

Step 4 โ€” Check script permissions

# Script must be executable
chmod +x /usr/local/bin/backup.sh

# Check who cron runs as (usually root for system crontab)
# User crontab runs as that user
ls -la /usr/local/bin/backup.sh

Step 5 โ€” Test manually as cron would run it

# Run the exact command cron would run, with minimal environment
env -i PATH=/usr/bin:/bin HOME=/root SHELL=/bin/sh /usr/local/bin/backup.sh

# Check system cron logs
grep CRON /var/log/syslog | tail -20    # Ubuntu/Debian
grep cron /var/log/cron | tail -20      # CentOS/RHEL

Visualise all your cron jobs on a timeline

Paste your crontab -l output and see every job execution window, overlap detection, and a flock safety toggle for preventing duplicate runs.

Open Cron Visualiser โ†’

Frequently Asked Questions

Why does my cron job work when I run it manually but not via cron?

The environment is different. Cron runs with a minimal PATH, no home directory aliases, and no shell profile. Use absolute paths, set PATH explicitly in the crontab, and test with env -i to simulate the cron environment.

How do I prevent two instances of a cron job running at the same time?

Use flock: */15 * * * * flock -n /tmp/backup.lock /usr/local/bin/backup.sh. The -n flag means if the lock is already held (previous instance still running), skip this run instead of waiting.

What does MAILTO="" do in a crontab?

By default, cron tries to email output to the local user. MAILTO="" disables this. Without it, if sendmail isn't configured, cron jobs can silently fail or accumulate a mail queue.

How do I check if a cron job actually ran?

Check syslog: grep CRON /var/log/syslog | grep "your-script". Or add a timestamp to your log: echo "$(date): ran" >> /var/log/backup.log at the start of your script.