Cron expressions look like line noise until you learn the five positions. Once you do, most schedules are a variation on a handful of patterns. This page is a reference you can copy from, followed by the rules that are easy to get wrong.

The five fields

Position Field Range
1 Minute 0–59
2 Hour 0–23
3 Day of month 1–31
4 Month 1–12
5 Day of week 0–6, Sunday = 0

An asterisk means “every value in this field”. Lists use commas, ranges use hyphens, and a slash introduces a step. The expression */15 9-17 * * 1-5 therefore means “every 15 minutes, during hours 9 through 17, Monday through Friday”.

Common expressions

Schedule Expression
Every minute * * * * *
Every 5 minutes */5 * * * *
Every 10 minutes */10 * * * *
Every 15 minutes */15 * * * *
Every 30 minutes */30 * * * *
Hourly, on the hour 0 * * * *
Every two hours 0 */2 * * *
Daily at midnight 0 0 * * *
Daily at 02:30 30 2 * * *
Weekdays at 09:00 0 9 * * 1-5
Weekends at 10:00 0 10 * * 0,6
Every Monday at 09:00 0 9 * * 1
First day of the month 0 0 1 * *
Last day of the month 0 0 L * * (Quartz only)
Every quarter 0 0 1 1,4,7,10 *
Every six hours 0 */6 * * *
At 08:00 and 20:00 0 8,20 * * *
Every 5 minutes during business hours */5 9-17 * * 1-5
Once a year 0 0 1 1 *
Every 15 minutes, but not on the hour 1,16,31,46 * * * *

The last example is a reminder that */15 includes minute zero. If a downstream system already runs something on the hour, offset the schedule with explicit minutes instead of layering two jobs on the same tick.

The day-of-month OR rule

Traditional cron treats day-of-month and day-of-week as an OR, not an AND. The expression 0 0 1 * 1 does not mean “the first of the month, but only when it is a Monday”. It means “the first of the month or every Monday”.

If you need both conditions, the portable trick is to schedule one field and test the other inside the command:

# Run on the first of the month only if it is a Monday
0 0 1 * * [ "$(date +\%u)" = "1" ] && /usr/local/bin/monthly-report

Note the escaped %. In a crontab, an unescaped percent sign ends the command and starts stdin, which is one of the more obscure reasons a job “does nothing”.

Steps and ranges

  • 0-30/5 means every five minutes from 0 through 30.
  • 1-5 in the weekday field means Monday through Friday.
  • Month and weekday names work in many implementations: JAN, MON, WED.
  • 7 in the weekday field is Sunday in some implementations and invalid in others; prefer 0 for Sunday and 1-5 for weekdays.

Quartz is a different dialect

Quartz uses six or seven fields, with seconds first. It adds ? for “no specific value”, L for last, W for the nearest weekday, and # for the nth weekday of the month. A standard five-field expression pasted into Quartz will be read with the wrong positions, so always confirm which parser you are feeding.

Check before you ship

Two expressions can look correct and still fire at the wrong time. Put the expression into a next-run calculator with the target timezone, and confirm five consecutive timestamps. If the job touches money, backups or customer-visible data, also check what happens in the hour a daylight-saving transition occurs.

For the syntax rather than the examples, the cron syntax reference covers special characters in detail. To translate an expression you inherited, paste it into the cron explainer.