Guides
How to solve concrete problems with cron jobs, and know when they happen.
-
Why your cron job isn't running
Is your cron job not running, or your crontab not working? Check the service, the schedule, the time zone, the permissions and the differences between your terminal and cron's environment.
-
Cron logs: where to find them and how to check if a job ran
Where cron logs are on Ubuntu, Debian, RHEL and in Docker (grep CRON /var/log/syslog, journalctl -u cron), how to read them, and how to keep each job's output and exit code.
-
How to list and check cron jobs in Linux (all users)
crontab -l only shows yours. One command to list every user's cron jobs, plus /etc/crontab, /etc/cron.d, cron.daily and systemd timers.
-
How to run cron jobs in a Docker container
Run cron in a Docker container with a complete example for Debian and Alpine: keep cron in the foreground, see the jobs' output in docker logs, pass them the environment variables and set the time zone.
-
Cron time zone: is it UTC, and how to change it
Which time zone cron uses, how to see and change it, CRON_TZ in cronie, time zones in Docker, Kubernetes and systemd, and what happens when daylight saving time starts or ends.
-
How to prevent overlapping cron jobs with flock
Cron starts each run on time, even if the previous one is still running. How to skip or wait with flock, use it inside a script, and tell a skipped run from a failed one.
-
How to run a cron job every 30 seconds or less
Cron's smallest unit is the minute. How to run a job every 30 or 10 seconds with sleep in the crontab, or with a systemd timer, and what to watch for.
-
Crontab format: the five fields and their special characters
The syntax of a crontab line: the five fields of the schedule, the *, comma, dash and slash, the names of days and months, @daily and the other macros, and examples to copy.
-
How to run a cron job manually, now
Cron has no command to run a job now. How to run it by hand as cron would, with its user and environment, and how to run the jobs of /etc/cron.daily, systemd timers and Kubernetes now.
-
Cron job exit codes: what 1, 2, 126, 127 and 137 mean
What the exit code of a failed cron job means: 1 and 2, 124 from timeout, 126 and 127 when the command can't run, 137 and 143 when it was killed. And how to see it, since cron doesn't show it.
-
How to monitor cron jobs and get alerted when they fail
Cron doesn't tell you when a job fails, and says nothing when it stops running. The ways to monitor cron jobs: MAILTO, logs, alerts from the script and heartbeats, and what each one misses.
-
How to get an email when a cron job fails
Set up MAILTO so cron's emails actually arrive: send them through SMTP with msmtp, get them only when a job fails, find out why they don't arrive, and alert Slack, Discord or ntfy instead.