Skip to content

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

Cron dialects side by side
Unix cronQuartzAWS EventBridgeGitHub Actions
Number of fields56 or 765
Field orderminute, hour, day of month, month, day of weeksecond, minute, hour, day of month, month, day of week, optional yearminute, hour, day of month, month, day of week, yearminute, hour, day of month, month, day of week
Seconds fieldNoYes, firstNoNo
Year fieldNoOptional, 1970-2099Required, 1970-2199No
Day-of-week numbers0-6 with 0 = Sunday; cronie also accepts 71-7 with 1 = Sunday1-7 with 1 = Sunday0-6 or SUN-SAT
Extra charactersNone in POSIX; cronie adds / and ~/ ? L W #/ ? L W #/
Both day fields setRuns when either matchesNot supported: one must be ?Not allowed: one must be ?POSIX syntax
Time zoneThe system's; cronie has CRON_TZNot covered by the tutorialUTC for rules; any IANA zone in EventBridge SchedulerUTC by default
Shortest interval1 minute1 second1 minute5 minutes
Unix cron means the POSIX crontab format, with cronie, the implementation documented in the Linux crontab(5) manual page, where it differs.

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.

Common five-field cron expressions
ExpressionMeaning
*/5 * * * *Every 5 minutes
0 * * * *Every hour
0 */2 * * *On the hour, every 2 hours
0 9 * * 1-5At 09:00, Monday through Friday
0 9-17 * * 1-5Every hour, between 09:00 and 17:00, Monday through Friday
0 0 * * 0At 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 * 5At 04:30, on day 1 and 15 of the month, and on Friday
Meanings generated with the cronstrue library, version 3.14.0, in 24-hour format. The step values in the first and third rows are an extension that cronie, Quartz, AWS and GitHub Actions all accept.

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.

Quartz expressions from the Quartz CronTrigger tutorial
ExpressionMeaning in the Quartz documentation
0 0 12 * * ?Fire at 12pm (noon) every day
0 15 10 ? * MON-FRIFire 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 ? * 6LFire at 10:15am on the last Friday of every month
0 15 10 ? * 6#3Fire at 10:15am on the third Friday of every month
Expressions and meanings are quoted from the Quartz 2.3.0 CronTrigger tutorial.

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

Sources

This page was written from the primary sources below, read on .

Published by Hyperdusk Ltd. Last updated . Figures in computed tables were produced by the method stated under each table.

All guides→