Crontab cheat sheet

A crontab entry is five fields and a command, and almost every mistake comes from the same short list: the field order, what a step counts from, the day-of-week numbering and the timezone. This page collects the syntax, the symbols, the schedules people actually need, and the commands that keep them running. Every schedule in the tables links to a page that explains it in full.

The five fields

Field Values Notes
minute 0-59 The run starts on these minutes.
hour 0-23 24-hour clock. 0 is midnight.
day of month 1-31 Not every month has every day.
month 1-12 January is 1.
day of week 0-7 0 and 7 both mean Sunday.

Order matters: minute first, hour second. 30 3 * * * is 03:30. Written as 3 30, it asks for minute 3 of hour 30, which does not exist.

The symbols

  • *: every value in the field. * * * * * is every minute.
  • ,: a list. 1,15 in the day field is the 1st and the 15th.
  • -: a range, inclusive. 1-5 in the day-of-week field is Monday to Friday.
  • /: a step, counted from the first value of the field. */15 in the minute field is minutes 0, 15, 30, 45. 10-50/10 is 10, 20, 30, 40, 50.
  • ?: no specific value (Quartz-style schedulers only).
  • L: last day of the month (Quartz and cron-parser; plain Vixie crontab does not understand it).
  • W: the nearest weekday to a date (Quartz only).
  • #: the nth weekday of the month (Quartz only; Quartz numbers days from Sunday as 1), for example 6#2 for the second Friday.
  • @hourly, @daily, @weekly, @monthly, @yearly, @reboot: nicknames. @daily is 0 0 * * *.

Schedules people actually use

Expression Meaning Full page
* * * * * Every minute Read
*/5 * * * * Every five minutes Read
*/10 * * * * Every ten minutes Read
*/15 * * * * Every fifteen minutes Read
*/30 * * * * Every thirty minutes Read
0 * * * * Every hour, on the hour Read
0 */2 * * * Every two hours Read
0 */4 * * * Every four hours Read
0 */6 * * * Every six hours Read
0 0,12 * * * Twice a day, midnight and noon Read
0 0 * * * Every day at midnight Read
30 3 * * * Every day at 3:30 AM Read
0 9 * * 1-5 Weekdays at 9 AM Read
0 9 * * 0,6 Weekends at 9 AM Read
0 12 * * 0 Sundays at noon Read
*/15 9-17 * * 1-5 Every 15 minutes, weekdays 9 to 5 Read
0 0 1 * * First day of the month Read
0 0 1,15 * * The 1st and the 15th Read
0 0 L * * Last day of the month Read
0 0 1 1 * Once a year, January 1 Read

Missing a schedule? Build it in the generator or read the whole catalogue.

Commands that go with it

  • crontab -e: edit your crontab. Every entry is one line: five fields, then the command.
  • crontab -l: print what is installed.
  • crontab -r: remove the crontab. It does not ask twice.
  • grep CRON /var/log/syslog: see the daemon's own log on Debian-family hosts; on RHEL-family it is /var/log/cron.
  • systemctl status cron: the daemon's state on Debian-family hosts (crond on RHEL-family).
  • >> /var/log/job.log 2>&1: append both streams to a file. Without a redirect, cron mails the output to MAILTO, and on a server that mail goes nowhere.
  • flock -n /tmp/job.lock: one line in front of the command stops a second copy from running while the first is still working.

Test before you trust it

A schedule is only as good as the environment the job runs in. Three checks catch most failures before they cost a night:

  1. Paste the expression into the parser and read the next runs. If they are not what you expected, the expression is wrong, not the cron.
  2. Run the command by hand as the cron user. sudo -u www-data /usr/bin/php /var/www/job.php finds permission problems while you are still watching.
  3. Print date and pwd inside the job for its first day. The timezone and the working directory are the two things cron does not inherit from your shell.

FAQ

Where does the crontab live on disk?

Debian-family systems keep one file per user under /var/spool/cron/crontabs/; RHEL-family under /var/spool/cron/. Edit it through crontab -e, not with an editor: the daemon expects the file to be owned correctly and a manual save can break that.

Why does a job work by hand but not from cron?

The shell you type in and the shell cron runs are different. Cron starts with a minimal PATH, no aliases and no terminal. Absolute paths, explicit environment variables and a redirect for output fix most of these; the mistakes page walks through the rest.

Does cron catch up on missed runs?

No. A run that was missed while the machine was off is skipped. @reboot runs once at startup, and systemd timers or anacron add catch-up behaviour when the job must not skip a day.