Cron Expression Syntax

A cron expression is five fields that tell a scheduler which minutes to run a job. Each field is simple; the way they combine has a few traps.

What a cron expression describes

Cron is the classic Unix scheduler. A background process, the cron daemon, wakes up once a minute, reads a table of jobs called a crontab, and runs every job whose schedule matches the current minute. Each schedule is a cron expression: five fields separated by spaces, followed in the crontab by the command to run. Many other systems, such as CI services and job queues, reuse the same five-field format, sometimes with small extensions.

The five fields

PositionFieldAllowed values
1Minute0-59
2Hour0-23
3Day of month1-31
4Month1-12 (or jan-dec in many versions)
5Day of week0-7, where 0 and 7 are Sunday in many versions (or sun-sat)

A job runs when the minute, hour, and month fields all match the current time and the day fields match as described further down. Some tools add a sixth field for seconds or years; standard crontab does not have one, so check which format a tool expects.

Special characters

  • * matches every value in the field.
  • , separates a list: 9,17 in the hour field means 9 and 17.
  • - gives an inclusive range: 1-5 in the day-of-week field means Monday to Friday.
  • / sets a step: */15 in the minute field expands to 0, 15, 30, 45, and 10-30/10 expands to 10, 20, 30.

Example expressions

ExpressionMeaning
0 * * * *At minute 0 of every hour
*/15 * * * *Every 15 minutes: at :00, :15, :30, :45
0 2 * * *Every day at 02:00
30 8 * * 1-5At 08:30, Monday to Friday
0 0 1 * *At midnight on the first day of each month
0 */6 * * *At 00:00, 06:00, 12:00 and 18:00
0 9,17 * * *At 09:00 and 17:00 every day
0 0 * * 0At midnight every Sunday
0 12 1 1 *At noon on 1 January

Sunday, 0 and 7

In the day-of-week field, 0 means Sunday, 1 means Monday, and so on up to 6 for Saturday. Many implementations, including Vixie cron and its descendants on most Linux systems, also accept 7 as Sunday, so 30 8 * * 0 and 30 8 * * 7 produce the same schedule. Using 0 is the portable choice.

When both day fields are set

The day-of-month and day-of-week fields interact in a way that surprises almost everyone. In classic cron (Vixie cron), if both fields are restricted, meaning neither is *, the job runs when either one matches. If one of them is *, only the other one matters. So 0 0 1,15 * 5 does not mean "the 1st or 15th, but only on a Friday". It means "the 1st, the 15th, and every Friday".

Shortcuts

Vixie cron and many related implementations accept named shortcuts in place of the five fields:

ShortcutEquivalent
@hourly0 * * * *
@daily (or @midnight)0 0 * * *
@weekly0 0 * * 0
@monthly0 0 1 * *
@yearly (or @annually)0 0 1 1 *
@rebootOnce, when the cron daemon starts

Which time zone?

Classic cron reads the schedule in the local time zone of the machine running the daemon, not the zone of the user who wrote it. A server set to UTC runs 0 9 * * * at 09:00 UTC, which is a different moment in each office around the world. Daylight saving changes make this worse: in zones that change clocks, a local time can be skipped or happen twice, and implementations differ in how they handle jobs in that window. Many teams keep servers on UTC to avoid the problem; the time zones and UTC page explains why.

Worked example: the next five runs

The times below come from a short Python matcher that steps forward one minute at a time from Saturday 2026-03-14 10:07 and applies the rules on this page, including the OR rule for the two day fields.

*/15 9-17 * * 1-5: every 15 minutes during working hours on weekdays

Mon 2026-03-16 09:00
Mon 2026-03-16 09:15
Mon 2026-03-16 09:30
Mon 2026-03-16 09:45
Mon 2026-03-16 10:00

The start is a Saturday, so nothing matches until Monday at 09:00.

0 0 1,15 * 5: the OR rule in action

Sun 2026-03-15 00:00
Fri 2026-03-20 00:00
Fri 2026-03-27 00:00
Wed 2026-04-01 00:00
Fri 2026-04-03 00:00

The 15th is a Sunday and still matches, as does every Friday, and 1 April, a Wednesday.

* 2 * * *: a common error

Sun 2026-03-15 02:00
Sun 2026-03-15 02:01
Sun 2026-03-15 02:02
Sun 2026-03-15 02:03
Sun 2026-03-15 02:04

The minute field is *, so this fires sixty times between 02:00 and 02:59. To run once at 2 a.m., write 0 2 * * *.

Mistakes worth checking for

  • Star in the minute field. As shown above, * 2 * * * runs every minute of hour 2. Set the minute explicitly.
  • Uneven steps. A step restarts at the top of the range. */7 in the minute field gives 0, 7, 14, 21, 28, 35, 42, 49, 56, so the gap from :56 to the next :00 is only four minutes.
  • Expecting AND across the day fields. Setting both day-of-month and day-of-week gives OR in classic cron. To run on "the first Monday", run on Mondays and test the date inside the script.
  • Different environment. Cron jobs run with a minimal environment and a short PATH. Use full paths to programs and files, and make sure the script has execute permission.
  • Unescaped percent signs. In a crontab command line, % is treated as a newline unless escaped as \%, which often breaks date +%F.
  • Lost output. Output may be mailed to the user or discarded. Redirect it to a log file so failures leave a trace.