How to Build a Cron Expression (With Examples)
Build cron expressions field by field, with what steps really do when they do not divide evenly (measured: */7 leaves a 4-minute gap each hour), how cronie decides the day-of-month/day-of-week OR rule, and how Quartz, AWS and GitHub Actions differ.
The Five Fields
A standard crontab line has five fields: minute (0-59), hour (0-23), day of month (1-31), month (1-12 or JAN-DEC) and day of week (0-7 or SUN-SAT, where both 0 and 7 mean Sunday). Each field takes a value, a range (1-5), a list (1,15), a step (*/5 or 9-17/2) or * for every value. 30 9 * * 1-5 is 09:30 on weekdays.
Common Schedules
| Schedule | Expression |
|---|---|
| Every 15 minutes | */15 * * * * |
| Hourly, on the hour | 0 * * * * |
| Daily at 02:30 | 30 2 * * * |
| Weekdays at 18:00 | 0 18 * * 1-5 |
| Every 2 hours in working hours | 0 9-17/2 * * 1-5 (09, 11, 13, 15, 17) |
| First of the month at noon | 0 12 1 * * |
| Sundays at 02:00 | 0 2 * * 0 |
Steps That Do Not Divide Evenly: Measured
A step does not mean "every n units forever". It means every n-th value within the field, starting again at the field's first value each hour, day or month. When n does not divide the field evenly, the last interval is short. We listed the next runs with croniter and with our own cron engine (they agree on all seven; October 13, 2026, UTC):
| Expression | What people expect | What runs | Intervals |
|---|---|---|---|
*/7 * * * * | every 7 minutes | :00, :07 … :56, then :00 | 7 min, plus a 4-min gap each hour |
*/25 * * * * | every 25 minutes | :00, :25, :50, :00 | 25, 25, 10 min |
*/45 * * * * | every 45 minutes | :00, :45, :00, :45 | 45, 15 min |
0 */5 * * * | every 5 hours | 00, 05, 10, 15, 20, 00 | 5 h, plus 4 h overnight |
0 */7 * * * | every 7 hours | 00, 07, 14, 21, 00 | 7 h, plus 3 h overnight |
0 0 */10 * * | every 10 days | 1st, 11th, 21st, 31st | 10 days, or 1 day after the 31st |
0 9-17/2 * * 1-5 | every 2 hours, 9-17 | 09, 11, 13, 15, 17 | 2 h, then 16 h |
If you need a true fixed interval that does not fit the field, cron cannot express it in one line. Use a divisor of 60 or 24, run more often and let the job skip work it does not need, or use a scheduler with interval syntax (a systemd timer with OnUnitActiveSec=, for example).
Day of Month and Day of Week Together
When both day fields are restricted, cron runs on days matching either: 0 0 13 * 5 runs on the 13th and on every Friday, not only on Friday the 13th. The detail most guides miss is how cron decides a field is "restricted". In cronie, the cron on most Linux systems, a field counts as unrestricted whenever it starts with an asterisk, including steps like */10; if either field is unrestricted, the two are ANDed. So 0 0 */10 * 1 in cronie runs only on Mondays that fall on the 1st, 11th, 21st or 31st (next: December 21, 2026), while croniter, a widely used Python library, treats */10 as restricted and runs on those dates or any Monday. Check which your scheduler follows before combining a day-of-month step with a weekday.
Testing this turned up a bug in our own tools: with */10 in the day-of-month field and * for the weekday, the shared engine behind the Cron Builder, Crontab Explainer and Cron Next Fire matched every day. It now follows cronie's rule exactly (fixed October 13, 2026).
Not Every "Cron" Is Five Fields
- Quartz (Java) adds a leading seconds field and an optional year, and requires
?in one of the two day fields. - AWS EventBridge uses six fields (with year), also requires
?in one day field, and runs in UTC unless you use EventBridge Scheduler with a time zone. - GitHub Actions
scheduleuses five-field POSIX syntax in UTC, and the shortest interval it runs is every 5 minutes. - Kubernetes CronJob uses five fields and accepts a
timeZonefield.
The Cron Builder writes five-field POSIX expressions, describes them in English and lists the next five runs in a time zone you choose.
Frequently Asked Questions
What is a cron expression?
How do I schedule a cron job for every 5 minutes?
What does * mean in a cron expression?
- [1]cronie source, src/entry.c and src/cron.c (DOM_STAR/DOW_STAR rule), checked Oct 13, 2026 ↗
- [2]POSIX.1-2024, crontab utility ↗
- [3]croniter (Python library used as a second reference) ↗
- [4]Quartz Scheduler, CronTrigger tutorial ↗
- [5]AWS, EventBridge cron expressions reference ↗
- [6]GitHub Docs, Events that trigger workflows: schedule ↗
- [7]Kubernetes, CronJob (time zones) ↗