Five-Field vs. Six-Field Cron Expressions
The number of fields does not identify a cron dialect. Here is what changes between schedulers and why you cannot just add or drop a field.
People say 'cron expression' as if it were one standard, but the format has several dialects, and the number of fields is only the most visible difference. An expression that works in a crontab can be rejected, or worse, accepted with a different meaning, in Quartz, Spring or AWS EventBridge.
The layouts side by side
| Dialect | Fields | Weekday numbering | Notable syntax |
|---|---|---|---|
| Unix/Linux cron | minute hour day-of-month month day-of-week | 0-7, with 0 and 7 as Sunday | Macros such as @daily and @reboot |
| Kubernetes CronJob | same five fields | 0-6, 0 is Sunday | Macros; timezone set in .spec.timeZone |
| Generic six-field | second minute hour day-of-month month day-of-week | Usually 0-7 | Library-specific; confirm with yours |
| Quartz | second minute hour day-of-month month day-of-week [year] | 1-7, 1 is Sunday | ? L W # and an optional year |
| Spring | second minute hour day-of-month month day-of-week | 0-7, 0 and 7 are Sunday | L, W, #, ? and macros |
| AWS EventBridge | minute hour day-of-month month day-of-week year | 1-7, 1 is Sunday | cron(...) wrapper, ?, L, W, #; the year is required |
Notice that six fields can mean 'seconds first' (Quartz, Spring) or 'minute first with a year last' (EventBridge). The same six tokens may therefore be valid in more than one dialect and mean different things.
Why the field count alone does not tell you the dialect
Take 0 0 12 ? * MON. The question mark suggests Quartz, but Spring also accepts it, and a generic seconds-based library might too. A tool can narrow the possibilities, but only you know which scheduler will run the expression. For that reason a good cron tool asks for the dialect and reports an ambiguity instead of guessing.
Never fix a field count by deleting a field
If a five-field scheduler rejects a six-field expression, dropping the first field is not a fix unless that field was 0 and the rest has the same meaning. Otherwise you silently change the schedule.
Converting between dialects
A faithful conversion adjusts three things: the field layout, the weekday numbers, and the day-field rules. Here is the same weekday schedule written for three schedulers.
0 9 * * MON-FRI # Unix cron, Kubernetes (09:00 Monday to Friday)
0 0 9 ? * MON-FRI # Quartz: seconds added, ? marks the unused day field
cron(0 9 ? * MON-FRI *) # AWS EventBridge: year added, ? requiredUsing weekday names makes this much safer than numbers. Written as 1-5, the same schedule means Monday to Friday in Unix cron and Sunday to Thursday in Quartz.
Some expressions cannot be converted at all. Unix cron matches a day when either the day-of-month or the day-of-week matches, but Quartz and EventBridge allow only one of the two to be set. If an expression restricts both, there is no Quartz equivalent. The same applies in the other direction to operators such as L, W and #, which standard Unix cron lacks.
Checking a conversion
Two expressions that look alike are not necessarily equivalent. The Cron Builder on DevCraftKit checks an expression against each supported dialect, shows a conversion only when it can preserve the meaning, and compares the next run times of the original and the converted expression. A matching preview is good evidence over that window; it is not a mathematical proof.
Conclusion
Treat cron as a family (the basics are in Cron syntax explained). Decide which scheduler runs your expression, write it in that dialect, prefer names over numbers for weekdays and months, and verify the upcoming run times before relying on it.
Frequently asked questions
- How do I convert a five-field cron expression to Quartz?
- Add a seconds field at the start, put a question mark in whichever of day-of-month and day-of-week you are not restricting, and check the weekday numbers, because Quartz counts 1 as Sunday. For example 0 9 * * MON-FRI becomes 0 0 9 ? * MON-FRI. Expressions that restrict both day fields cannot be converted faithfully.
- Does Kubernetes cron support seconds?
- No. A CronJob schedule has five fields, so its shortest interval is one minute.
- Why is my six-field expression rejected?
- The scheduler probably expects a different layout. Some six-field dialects start with seconds, while AWS EventBridge starts with the minute and ends with a year. Check the documentation of the scheduler that will run the expression.
Try it yourself
The tool that pairs with this guide.
Did this help you sort out your server configuration?
If these free developer tools save you time, consider buying me a byte. Your support helps keep DevCraftKit free and growing.
Related articles
What Is .htaccess? A Practical Guide for Apache Sites
A per-directory configuration file for Apache: what it can do, where it stops working, and how to avoid the usual mistakes.
Published
Apache Rewrite Rules Explained: RewriteRule, RewriteCond and Flags
Understand how RewriteRule and RewriteCond fit together, what the flags do, and why per-directory rules behave differently.
Published
Cron Syntax Explained: A Complete Guide to Cron Expressions
What each cron field means, how ranges and steps are matched, and how to read an expression without guessing.
Published