Ping Clock Ping Clock

Cron job not running? Work through this list.

Know within minutes when a run is missed.

The job works when you run it by hand. In cron, nothing. Here's the order to check things, from most to least likely.

1. Is cron running?

systemctl status cron      # Debian, Ubuntu
systemctl status crond     # RHEL, Fedora, Amazon Linux

Containers often don't run a cron daemon at all unless you set one up.

2. Is the crontab installed for the right user?

crontab -l shows the current user's crontab. Jobs added with sudo crontab -e belong to root. Check both. System jobs live in /etc/crontab and /etc/cron.d/, which need an extra user field.

3. Did cron try to run it?

Look at the logs:

grep CRON /var/log/syslog          # Debian, Ubuntu
journalctl -u cron --since today   # systemd

A line with your command means cron started it, and the problem is in the job. No line means cron didn't, and the problem is in the schedule or crontab.

4. Is the schedule what you think?

Paste it into a cron explainer. Common slips:

  • * 2 * * * runs every minute of the 2 o'clock hour, not once
  • Day of month and day of week combine with OR, not AND
  • The server's time zone isn't yours: check with date and timedatectl

5. Does the command work in cron's environment?

Cron starts with a tiny environment. Typical failures:

  • PATH. Commands found in your shell aren't found by cron. Use absolute paths or set PATH= at the top of the crontab.
  • Shell. Cron uses /bin/sh by default, not bash. Bash-only syntax breaks. Set SHELL=/bin/bash or call bash explicitly.
  • Home directory and dotfiles. Your .bashrc and .profile aren't loaded, so aliases and exported variables are missing.
  • Working directory. Relative paths start from the user's home, not the script's folder. cd first.

Test with the same environment:

env -i /bin/sh -c '/path/to/your/command'

6. Are there percent signs?

In a crontab line, % means newline. date +%F breaks. Escape it as \%, or move the command into a script.

7. Permissions

Is the script executable (chmod +x)? Can the cron user read the files and write to the output folder? Is the script on a mount that isn't available at run time?

8. Syntax errors elsewhere in the file

Some cron versions skip the whole crontab after an error. Others ignore a last line without a trailing newline. Run crontab -l and read it carefully.

9. Is it running but failing silently?

Redirect output so you can see what happens:

0 2 * * * /path/to/job.sh >> /tmp/job.log 2>&1

Then read the log after the next run.

10. Is something else stopping it?

/etc/cron.allow and /etc/cron.deny control who can use cron. SELinux or AppArmor can block scripts. A lock file left by a crashed run can make flock skip every future run.

Stop finding out late

Most "cron not running" problems are discovered days later, when someone notices missing data. Add a heartbeat ping to every job that matters. If it doesn't run, the ping doesn't arrive, and you get an alert within the grace time you set, not a week later.

Questions

The job runs but at the wrong time.

Time zone. Compare date on the server with the time you expected.

It worked yesterday and stopped today.

Look for changes: a server rebuild, an OS upgrade, a password or token rotation, a full disk.

Add a heartbeat check