Cron Syntax Compared: Unix, Quartz, AWS, GitHub Actions
Last updated Published by Hyperdusk Ltd
The short answer
Unix cron uses five fields: minute, hour, day of month, month and day of week. Quartz adds a seconds field at the start and an optional year at the end. AWS EventBridge uses six fields with the year last and no seconds. GitHub Actions uses the five-field form, in UTC by default. The dialects also number weekdays differently.
Generate a cron expression from a plain-English schedule →Key differences
| Unix cron | Quartz | AWS EventBridge | GitHub Actions | |
|---|---|---|---|---|
| Number of fields | 5 | 6 or 7 | 6 | 5 |
| Field order | minute, hour, day of month, month, day of week | second, minute, hour, day of month, month, day of week, optional year | minute, hour, day of month, month, day of week, year | minute, hour, day of month, month, day of week |
| Seconds field | No | Yes, first | No | No |
| Year field | No | Optional, 1970-2099 | Required, 1970-2199 | No |
| Day-of-week numbers | 0-6 with 0 = Sunday; cronie also accepts 7 | 1-7 with 1 = Sunday | 1-7 with 1 = Sunday | 0-6 or SUN-SAT |
| Extra characters | None in POSIX; cronie adds / and ~ | / ? L W # | / ? L W # | / |
| Both day fields set | Runs when either matches | Not supported: one must be ? | Not allowed: one must be ? | POSIX syntax |
| Time zone | The system's; cronie has CRON_TZ | Not covered by the tutorial | UTC for rules; any IANA zone in EventBridge Scheduler | UTC by default |
| Shortest interval | 1 minute | 1 second | 1 minute | 5 minutes |
What are the five fields of a standard cron expression?
POSIX defines them as minute (0-59), hour (0-23), day of the month (1-31), month (1-12) and day of the week (0-6, with 0 as Sunday). Each field is an asterisk for every value, a number, a range such as 1-5, or a comma-separated list.
That is all POSIX defines. Step values such as */5, month and day names, and 7 as a second way to write Sunday are extensions. cronie supports all three, plus ~ for a random value in a range and nicknames such as @daily and @reboot. An expression that uses only numbers, ranges, lists and asterisks is the most portable.
| Expression | Meaning |
|---|---|
| */5 * * * * | Every 5 minutes |
| 0 * * * * | Every hour |
| 0 */2 * * * | On the hour, every 2 hours |
| 0 9 * * 1-5 | At 09:00, Monday through Friday |
| 0 9-17 * * 1-5 | Every hour, between 09:00 and 17:00, Monday through Friday |
| 0 0 * * 0 | At 00:00, only on Sunday |
| 0 0 1 * * | At 00:00, on day 1 of the month |
| 30 4 1,15 * * | At 04:30, on day 1 and 15 of the month |
| 0 0 1 1 * | At 00:00, on day 1 of the month, only in January |
| 30 4 1,15 * 5 | At 04:30, on day 1 and 15 of the month, and on Friday |
What happens when both day fields are set?
In Unix cron, the job runs when either one matches. POSIX states it, and the cronie manual gives the example in the last row of the table: 30 4 1,15 * 5 runs at 4:30 am on the 1st and 15th of each month, plus every Friday. It does not mean "the 1st and 15th, if a Friday".
Quartz and AWS avoid the question. Both add a ? character meaning "no specific value", and both require it in one of the two day fields.
How is Quartz cron different?
A Quartz expression has six or seven fields. Seconds come first and an optional year comes last, so the five-field 0 9 * * 1-5 is not a valid Quartz expression. Days of the week are numbered 1 to 7 starting from Sunday, so 1-5 in Quartz means Sunday to Thursday. Use names such as MON-FRI to avoid the off-by-one.
Quartz also adds L for last, W for the nearest weekday and # for the nth weekday of the month.
| Expression | Meaning in the Quartz documentation |
|---|---|
| 0 0 12 * * ? | Fire at 12pm (noon) every day |
| 0 15 10 ? * MON-FRI | Fire at 10:15am every Monday, Tuesday, Wednesday, Thursday and Friday |
| 0 15 10 15 * ? | Fire at 10:15am on the 15th day of every month |
| 0 15 10 L * ? | Fire at 10:15am on the last day of every month |
| 0 15 10 ? * 6L | Fire at 10:15am on the last Friday of every month |
| 0 15 10 ? * 6#3 | Fire at 10:15am on the third Friday of every month |
How is AWS EventBridge cron different?
An AWS expression is written cron(minutes hours day-of-month month day-of-week year): six required fields, no seconds, and a year from 1970 to 2199. You cannot put a value or * in both day fields; one of them must be ?. Days of the week are 1 to 7 or SUN to SAT, with 1 as Sunday. Expressions that would run more often than once a minute are not supported.
So the Unix 0 9 * * 1-5 becomes cron(0 9 ? * MON-FRI *). AWS's own examples for rules are in UTC, such as cron(0 10 * * ? *) for 10:00 am UTC every day. EventBridge Scheduler uses the same six fields and lets you set an IANA time zone for the schedule. AWS now labels scheduled rules as legacy and points to EventBridge Scheduler.
What does GitHub Actions accept?
The schedule trigger takes POSIX cron syntax with five fields. GitHub documents four operators, *, ,, - and /, and accepts JAN-DEC and SUN-SAT as names. Nicknames such as @daily and @hourly are not supported.
Schedules run in UTC by default, and the shortest interval is once every 5 minutes. GitHub's documentation also describes an optional timezone key that takes an IANA time zone name, where that feature is available. It warns that scheduled runs can be delayed during periods of high load, including the start of every hour, so a job set for minute 0 may start late.
Which syntax should you write?
The one your scheduler documents. An expression copied from one system to another can be rejected or, worse, accepted with a different meaning, as with 1-5 in the day-of-week field.
When you can choose, start from a five-field expression that uses only numbers, ranges, lists and asterisks. It runs unchanged in Unix cron and GitHub Actions. For Quartz, put a seconds field in front, and for AWS add a year at the end; in both, replace one day field with ? and write weekdays as names.
Tools for this
- Generate a cron expression from a plain-English schedule →
Cron Expression Generator. Writes a cron expression from a description, explains each field of one you paste, and lists the next five run times. It handles five-field expressions and six-field expressions with a leading seconds field.
Sources
This page was written from the primary sources below, read on .
- crontab: schedule periodic background work
The Open Group (POSIX.1-2017). The five fields, their ranges, and the rule for when both day fields are set.
- crontab(5): Linux manual page
cronie project, hosted on man7.org. Step values, names, 0 or 7 for Sunday, random ranges, nicknames, CRON_TZ and the worked day-field example.
- CronTrigger Tutorial
Quartz Scheduler. The six or seven fields, their allowed values, the special characters and the examples.
- Setting a schedule pattern for scheduled rules (legacy) in Amazon EventBridge
Amazon Web Services. The cron() format, field ranges, wildcards, limitations and UTC examples.
- Schedule types in EventBridge Scheduler
Amazon Web Services. The same six-field cron format with a configurable IANA time zone.
- Events that trigger workflows: schedule
GitHub Docs. POSIX five-field syntax, supported operators, UTC default, the five-minute minimum, unsupported nicknames and delays under load.