env.dev

Cron Expression Syntax: A Complete Guide

Master cron expressions: field breakdown, special characters, and common schedule examples.

A cron expression is a string of 5 (or 6) fields that defines a recurring schedule for running automated tasks. It is the standard format used in Unix cron jobs, CI/CD pipelines, cloud schedulers (AWS EventBridge, GitHub Actions), and most backend job frameworks.

Field Layout

┌─────────── minute        (0–59)
│ ┌───────── hour          (0–23)
│ │ ┌─────── day of month  (1–31)
│ │ │ ┌───── month         (1–12 or JAN–DEC)
│ │ │ │ ┌─── day of week   (0–6 or SUN–SAT, 0=Sunday)
│ │ │ │ │
* * * * *

Some systems add a 6th field for seconds (Quartz, Spring) at the beginning, or a 6th year field at the end.

Special Characters

CharacterNameMeaning
*WildcardEvery value in the field
,ListMultiple values: 1,3,5
-RangeA range of values: 1-5
/StepEvery N values: */5 = every 5 minutes
LLastLast day of month or week (some implementations)
WWeekdayNearest weekday to given day (some implementations)
#Nth3rd Monday = MON#3 (some implementations)

Common Schedule Examples

* * * * *Every minute
*/5 * * * *Every 5 minutes
0 * * * *Every hour (at :00)
0 */2 * * *Every 2 hours
0 9 * * *Daily at 9:00 AM
0 0 * * *Daily at midnight
0 9 * * MON-FRIWeekdays at 9:00 AM
0 9 * * 1Every Monday at 9:00 AM
0 0 1 * *First day of every month at midnight
0 0 1 1 *Once a year on January 1st at midnight
30 8 * * 1-5Weekdays at 8:30 AM
0 0,12 * * *Twice daily: midnight and noon
0/30 * * * *Every 30 minutes (Quartz syntax)

Month and Day Names

Months

NumberName
1JAN
2FEB
3MAR
4APR
5MAY
6JUN
7JUL
8AUG
9SEP
10OCT
11NOV
12DEC

Days of Week

NumberName
0 (or 7)SUN
1MON
2TUE
3WED
4THU
5FRI
6SAT

Platform Differences

Watch out: AWS EventBridge and Quartz use a 6-field syntax with seconds as the first field. GitHub Actions uses standard 5-field cron but runs in UTC. Some systems treat 0 and 7 as Sunday for day-of-week. Always check your platform's documentation.

Parse and explain any cron expression with the Cron Expression Parser tool.