Guide
Building crontab entries that run reliably
Cron has run scheduled jobs on Unix systems for decades, and its five-field syntax is compact enough that most people look it up every time. Getting the schedule right is only half the job: a cron entry that works in a terminal often fails silently when cron runs it, because of paths, output and overlapping runs. This generator builds both the expression and a complete line that avoids those traps.
The five fields
A cron expression has five fields separated by spaces: minute (0–59), hour (0–23), day of month (1–31), month (1–12) and day of week (0–6, Sunday is 0). An asterisk means every value, a list such as 1,3,5 picks several, a range such as 1-5 covers a span and a step such as */15 means every fifteenth. The command follows on the same line.
Schedule modes
Every N minutes writes */N * * * *. Hourly runs at a chosen minute, optionally every few hours. Daily runs at a minute and hour, weekly adds a set of weekdays, and monthly a day of the month. Custom mode exposes all five fields for anything else, such as a quarter-hour schedule only during office hours: */15 9-17 * * 1-5.
Making the job dependable
Cron runs commands with a minimal environment, often /bin/sh and a short PATH, so the generator encourages an absolute path to the command. Output is appended to a log file with >> file 2>&1, so both normal output and errors are kept, or discarded to /dev/null if you leave the log empty. With overlap prevention on, the command is wrapped in flock -n with a lock file, so if one run is still busy when the next starts, the new one exits instead of piling up. Percent signs are escaped automatically, because in a crontab an unescaped % ends the command and starts its standard input, which breaks commands such as date +%F.
A worked example
The default settings describe a weekday backup at 09:30. The expression is 30 9 * * 1,2,3,4,5, and cronstrue reads it back as “At 09:30 AM, only on Monday, Tuesday, Wednesday, Thursday, and Friday”. The full line is a # Weekday backup comment followed by 30 9 * * 1,2,3,4,5 flock -n /tmp/Weekday_backup.lock /usr/local/bin/backup.sh >> /var/log/backup.log 2>&1. Below it, the next five run times are listed in your local time zone.
Day-of-month and day-of-week together
When both day fields are restricted, standard cron runs the job if either matches, not both. 0 9 1 * 1 therefore runs on the first of every month and on every Monday. To run on “the first Monday”, schedule every Monday from day 1 to 7 and test the date in the script, or schedule 0 9 1-7 * * and check that the day is Monday.
Time zones
Cron uses the server’s time zone. Containers and cloud servers are often set to UTC, so a job meant for 09:30 local time may need a different hour. Some cron implementations accept CRON_TZ=Europe/London at the top of the crontab; check yours before relying on it, and remember that jobs scheduled in the hour skipped or repeated by daylight saving time can run zero or two times.
Installing the line
Run crontab -e, paste the line, save and exit; crontab -l lists what is installed. For system-wide jobs in /etc/cron.d, add the user name between the schedule and the command.
Related tools
- Cron Expression Parser explains an existing expression and lists up to 50 next runs.
- systemd Unit Generator creates a timer, the modern alternative to cron.
- Linux Command Builder helps write the find or tar command the job runs.
- rsync Command Builder prepares a backup command to schedule.
Checked against the current version of the Crontab Generator on .

