buildcron

Cron Format & Syntax Cheatsheet

The cron format is five fields separated by spaces — minute, hour, day of month, month and day of week — and a job runs whenever the current time matches all five. Each field takes a number, a range, a list, a step, or * for “every value”.

┌───────────── minute        (0–59)
│ ┌─────────── hour          (0–23)
│ │ ┌───────── day of month  (1–31)
│ │ │ ┌─────── month         (1–12 or JAN–DEC)
│ │ │ │ ┌───── day of week   (0–7 or SUN–SAT; 0 and 7 are Sunday)
│ │ │ │ │
* * * * *  command to run

The cron format: five fields

The format dates back to the original Unix cron, and Vixie cron, cronie, Kubernetes CronJobs and GitHub Actions all read it the same way. The fields always come in this order, from the smallest unit of time to the largest, with the day of week last:

#FIELDVALUESNOTES
1Minute0–59Minute past the hour.
2Hour0–2324-hour clock; 0 is midnight, 12 is noon.
3Day of month1–31Days a month doesn't have are skipped.
4Month1–12, JAN–DECNames aren't case-sensitive.
5Day of week0–7, SUN–SAT0 and 7 are both Sunday.

Operators

Four symbols cover every standard schedule, and they can be combined within a field.

SYMBOLMEANINGEXAMPLEREADS AS
*Every value the field allows* * * * *every minute
,A list of values0 8,17 * * *at 08:00 and 17:00
-A range, including both ends0 9-17 * * *every hour from 09:00 to 17:00
/A step through a range*/15 * * * *every 15 minutes: :00, :15, :30, :45

A step always counts from the start of its range: */15 is shorthand for 0-59/15, and 10-50/20 gives 10, 30 and 50. Combining operators works too — 0 9-17/2 * * 1-5 runs at 9, 11, 13, 15 and 17 o'clock on weekdays.

Field by field

Minute (0–59)

The minute field is the one to double-check: * here means every minute, so an hourly job needs a number, not a star.

VALUEMEANING
0on the hour
30at half past
0,30on the hour and at half past
*/10every 10 minutes: 0, 10, 20, 30, 40, 50
5-59/10every 10 minutes starting at :05

Hour (0–23)

Hours use a 24-hour clock with no am or pm, and they're in the timezone of the machine running cron.

VALUEMEANING
0midnight
909:00
9-17every hour from 09:00 to 17:00
*/600:00, 06:00, 12:00 and 18:00
1-23/2every odd hour: 01:00, 03:00 … 23:00

Day of month (1–31)

Cron never moves a run to another day, so a date a month doesn't have — the 31st of April, say — is simply skipped. There's no symbol for “the last day”.

VALUEMEANING
1the 1st
15the 15th
1,15the 1st and the 15th
1-7the first seven days
*/2odd days: 1, 3, 5 … 31

Month (1–12 or JAN–DEC)

Months count from 1, so a step such as */3 starts in January. Month names work in ranges too — JAN-MAR is January to March.

VALUEMEANING
1 or JANJanuary
6-8June, July and August
*/3January, April, July and October
1,7January and July

Day of week (0–7 or SUN–SAT)

The week starts on Sunday at 0; 7 is accepted as Sunday too, so 1-7 means Monday to Sunday. Day names work as single values, in lists (MON,WED,FRI) and in ranges (MON-FRI) — Vixie cron and cronie, which most Linux systems run, accept all three. The crontab man page still documents names as single values only, so numbers are the safest choice for other schedulers.

VALUEMEANING
0 or 7Sunday
1-5Monday to Friday
6,0Saturday and Sunday
MONMonday

How day of month and day of week combine

The two day fields follow a special rule. If either one starts with * — plain *, or a step such as */2 — a day has to match both. If neither starts with *, cron runs the job on days that match either field. So 0 0 13 * 5 runs at midnight on the 13th of every month and on every Friday, not only on Friday the 13th, while 0 0 */2 * 1 runs only on odd-numbered days that are also Mondays.

To require both — “the first Monday”, “Friday the 13th” — restrict one field in the expression and check the other inside the command. The every Monday and every Friday pages show the pattern.

Special strings

Most crons accept these shortcuts in place of the five fields:

SHORTCUTSAME ASRUNS
@rebootOnce, when the cron daemon starts (normally at boot)
@yearly, @annually0 0 1 1 *Midnight on 1 January
@monthly0 0 1 * *Midnight on the 1st of each month
@weekly0 0 * * 0Midnight at the start of Sunday
@daily, @midnight0 0 * * *Midnight every day
@hourly0 * * * *At minute 0 of every hour

Writing a crontab line

A crontab line is the five fields followed by the command:

# m  h  dom mon dow  command
  30 2  *   *   *    /usr/local/bin/backup.sh >> /var/log/backup.log 2>&1
  • crontab -e edits your own crontab and crontab -l lists it.
  • System files — /etc/crontab and the files in /etc/cron.d/ — have an extra field naming the user to run as, between the schedule and the command.
  • Jobs run with a minimal environment; PATH is often just /usr/bin:/bin. Use absolute paths, or set PATH= at the top of the crontab.
  • A % in the command is turned into a newline, so escape it as \\% — for example in date +\\%F.
  • Output is emailed to the crontab's owner, or to the address in MAILTO=, if the machine can send mail. Redirect it to a file to keep a log.

Non-standard syntax you might see

Other schedulers extend cron's syntax. None of these work in a standard crontab:

  • A seconds field at the front — Quartz, Spring and several libraries use six or seven fields.
  • ? for “no specific value” in one of the day fields — Quartz and AWS EventBridge require it.
  • L for the last day of the month, W for the nearest weekday, and # for the nth weekday (6#3 is the third Friday in Quartz, where Sunday is 1).
  • H in Jenkins, which picks a consistent pseudo-random value per job so that H * * * * spreads hourly jobs across the hour.

Common mistakes

  • * 2 * * * runs every minute from 02:00 to 02:59 — sixty times. For once at 2am, write 0 2 * * *.
  • Restricting both day fields and expecting AND: 0 0 1-7 * 1 isn't “the first Monday”.
  • Scheduling on the 29th, 30th or 31st and expecting a run every month.
  • Writing 24 for midnight — the hour field stops at 23.
  • Forgetting that times are in the server's timezone, which is often UTC.

To check an expression against all of this, paste it into the cron expression validator, or browse the examples for ready-made schedules.

Frequently asked questions

What are the five fields of a cron expression?

In order: minute (0–59), hour (0–23), day of month (1–31), month (1–12) and day of week (0–7, where 0 and 7 are Sunday). They're separated by spaces, and the command to run follows the fifth field.

What does an asterisk mean in cron?

* means every value the field allows — every minute, every hour, every day and so on. A field set to * doesn't restrict the schedule at all.

What's the difference between a comma and a hyphen in cron?

A comma lists separate values — 1,15 is the 1st and the 15th. A hyphen is an inclusive range — 1-15 is every day from the 1st to the 15th.