Why is my cron job not running?

On this page

Most cron jobs that never run fail in one of a dozen ways. Go down the list in order: the scheduler itself, the schedule line, the environment, then the command. Each step takes a minute and rules out a whole class of causes.

Is the scheduler running?

  • Linux with systemd: run systemctl status cron (Debian and Ubuntu) or systemctl status crond (Red Hat family). Start it and enable it at boot if it is stopped.
  • Containers: most images ship without a cron daemon and without a process that starts it. A crontab file in the image does nothing until a daemon runs.
  • Windows: open Task Scheduler and check the task is enabled and its trigger has a start time in the future or an active repetition.
  • Managed platforms: look for a disabled flag, a plan limit or an inactive-repository rule. GitHub Actions, Vercel and Heroku each have one.

Is the schedule line valid and in the right file?

  • List the crontab with crontab -l as the user that owns the job. A job in your own crontab does not run for root and the reverse.
  • Files in /etc/cron.d and /etc/crontab have an extra column, the user name; user crontabs do not.
  • Check the five fields in the cron explainer. A field out of range, or a line that ends without a newline, can make a whole file be ignored.
  • cron(8) checks crontab files for changes every minute and reloads them, so a saved edit takes effect within about a minute without a restart.

Is the environment what you expect?

Cron does not read your login files. It sets SHELL to /bin/sh and takes LOGNAME and HOME from the account entry, according to crontab(5). A command that finds node or python through your shell profile will not find it under cron. Use absolute paths, or set PATH at the top of the crontab. Cron environment and PATH goes into this.

Does the command itself work?

  • Run the exact command with a clean environment: env -i /bin/sh -c 'your command'.
  • A percent sign in the command is turned into a newline unless escaped as \%, and everything after the first one is passed to the command as standard input.
  • Make sure the script is executable and has a valid shebang line.
  • Write the output to a file, such as >> /var/log/job.log 2>&1, so a failure leaves evidence. See cron logs.

Did the clock change?

Jobs set for a time inside a daylight saving gap may be moved or skipped. cron(8) describes the rule for changes of under three hours. See cron time zones and daylight saving.

Sources

Questions and answers

How do I know whether cron even started the job?
Look in the system log. On systemd machines run journalctl -u cron (or crond). Each job start is logged with the user and the command, unless logging was turned down.
How do I stop this from happening unnoticed again?
Add a ping to the end of the job and a check that expects it. The next time the job does not run, you hear about it that day, not weeks later.
Know the moment a job goes quiet

Create a check, add one curl to the job, and CronMissed alerts you when a ping is late or reports a failure.

Start monitoring