A cron expression is five small numbers that decide when code runs in production. They are easy to write and easy to misread, and the mistakes show up weeks later: a report that never arrives in March, an invoice sent twice in November. This guide covers the traps that cause most of them.
The five fields
┌ minute (0-59)
│ ┌ hour (0-23)
│ │ ┌ day of month (1-31)
│ │ │ ┌ month (1-12)
│ │ │ │ ┌ day of week (0-7, Sunday is 0 and 7)
* * * * *
Paste 30 2 * * * into the cron parser and it answers in words: “At 02:30”, then lists the next five runs. Always read that list before you deploy an expression. It takes ten seconds and catches most typing mistakes.
Trap 1: day of month OR day of week
Try 0 9 13 * 5 in the parser. You might expect “9:00 on Friday the 13th”. The parser says “At 09:00, on day 13 of the month or on Friday”, and the run list shows every Friday plus the 13th of each month, including a Sunday the 13th. When both day fields are restricted, standard cron runs when either matches.
If you need an AND, schedule on the day field that is more selective and test the other inside the script:
0 9 13 * * # then in the script: exit unless today is Friday
Trap 2: steps reset, they do not carry over
*/7 * * * * does not mean “every seven minutes”. It means minutes 0, 7, 14, … 56 of every hour, and then minute 0 again, four minutes after 56. For intervals that do not divide 60 evenly, you get uneven gaps. The parser’s run list shows this immediately. For true seven-minute spacing, use a loop or a scheduler that supports intervals.
Trap 3: Sunday is 0 and also 7
Both 0 and 7 mean Sunday in most implementations, so 0 0 * * 7 is a weekly Sunday job. The parser accepts it and prints “on Sunday”. Some tools accept only 0-6, so use 0 if the same expression travels between systems.
Trap 4: six fields from another system
Quartz, Spring and some cloud schedulers put a seconds field first or add a year. In standard cron that is an error. Give the parser 0 0 0 * * * and it tells you it found six fields and looks like a Quartz or Spring expression, instead of silently shifting every field by one place.
Trap 5: daylight saving time
This is the one that costs money. The parser shows run times in UTC, and UTC has no daylight saving. A system cron daemon uses the server’s local zone, and a local zone with DST has a day that skips an hour and a day that repeats one. In New York in 2026:
- 8 March: clocks jump from 02:00 to 03:00. Local times from 02:00 to 02:59 do not exist. A job at
30 2 * * *has no 02:30 that day. - 1 November: clocks go back from 02:00 to 01:00. Local times from 01:00 to 01:59 happen twice, once in EDT and once in EST. A job at
30 1 * * *has two 01:30 moments.
What a scheduler does about this varies. Some run the skipped job right after the jump, some skip it, and some run the repeated hour twice. Do not rely on any of those behaviours without testing the implementation you use.
How to schedule so DST cannot bite
- Run in UTC when you can. Servers, containers and many hosted schedulers let you set the zone. Convert once, write the expression in UTC, and add a comment that says which local time it represents.
- Avoid the 01:00-03:00 window in local time if you must use a DST zone. In most zones midday and the evening never fall in a gap, but check your zone’s change time.
- Make jobs idempotent. If a job can run twice, running it twice should do no harm: use a lock, a “last run” record or a unique key per day.
- Use the scheduler’s time zone field when it has one, instead of converting by hand.
- Log the start time in UTC so a double run is obvious in the logs.
Build, then check
If you do not write cron by heart, assemble the expression in the cron builder and then paste it into the parser to read it back in words. When a log shows a run at an unexpected moment, convert the timestamp with the Unix timestamp converter to see which date and zone it falls in.
The parser and builder run in your browser. The expressions you paste, which often name internal jobs, are not uploaded.
Frequently asked questions
What do the five fields of a cron expression mean?
Minute (0-59), hour (0-23), day of the month (1-31), month (1-12) and day of the week (0-7, where both 0 and 7 mean Sunday). An asterisk means every value, a slash gives a step and a comma gives a list.
Why does `0 9 13 * 5` run every Friday and not only on Friday the 13th?
In standard cron, when both the day-of-month and day-of-week fields are restricted, a day matches if either one matches. It is an OR, not an AND. To get Friday the 13th only, schedule a daily job and check the date in the script.
My expression has six fields. What is wrong?
Standard cron has five. A sixth field usually means a seconds field from Quartz or Spring, which uses a different syntax. The parser here says so instead of guessing.
What time zone does cron use?
It depends on where it runs. The system cron daemon uses the server's local time zone. GitHub Actions and Cloudflare cron triggers use UTC. Kubernetes CronJobs can set a timeZone field. Always check the documentation of the scheduler you actually use.
More guides
- CIDR notation: why a /31 has two usable hosts, what a /32 is for, and the subnet mistakes to avoid
- Hashing is not encryption: what a hash can do, and why passwords need bcrypt
- Unix timestamps: seconds, milliseconds or microseconds, and the dates where they go wrong
- UUID v4, UUID v7 and ULID: which ID to use, and what is inside each
- Base64 is not encryption: what it does, and the bugs it causes
- JSON, CBOR, MessagePack and Protobuf: the same data in four sets of bytes
- Regex backtracking: how one innocent pattern can freeze a server (ReDoS)
- URL encoding pitfalls: %20 or +, double encoding, and the characters that break links
- CSV edge cases: quotes, newlines, delimiters and the leading zero
- Why JSON silently changes your big numbers (and how to stop it)
- JWT pitfalls: decoding a token is not verifying it
- YAML surprises: the Norway problem, octal numbers and version strings