"Run this every weekday at 9" is one sentence. Across the schedulers a typical team touches, it is six different strings, and two of the obvious ones are wrong in a way nothing warns you about: the job runs, just on the wrong day or at the wrong hour.
The same schedule, six ways
| Platform | Weekdays at 09:00 |
|---|---|
| crontab | 0 9 * * 1-5 |
| Quartz / Spring | 0 0 9 ? * MON-FRI |
| AWS EventBridge | cron(0 9 ? * MON-FRI *) |
| GitHub Actions | 0 9 * * 1-5 |
| Kubernetes CronJob | 0 9 * * 1-5 |
| systemd OnCalendar | Mon..Fri *-*-* 09:00:00 |
Quartz adds a seconds field in front. EventBridge wraps the expression in cron( ) and adds a year at the end. Both need ? in one of the two day fields. systemd does not use cron syntax at all.
Trap 1: day 1 is not always Monday
In crontab, GitHub Actions and Kubernetes, 1 in the day-of-week field is Monday. In Quartz and AWS EventBridge, day 1 is Sunday. So 1-5 copied into Quartz means Sunday through Thursday, and the job quietly skips Friday.
The fix is boring and reliable: write day names. MON-FRI means the same thing everywhere that accepts names.
Trap 2: "first Monday" is an OR, not an AND
0 9 1-7 * 1 looks like "the first Monday of the month". When both day fields are set, crontab runs the job if either matches, so this runs on days 1 to 7 and on every Monday.
Some platforms can say "first Monday" directly:
- Quartz:
0 0 9 ? * 2#1 - AWS EventBridge:
cron(0 9 ? * MON#1 *) - systemd:
Mon *-*-01..07 09:00
crontab cannot, in one expression. Run it every Monday and exit unless the day of the month is 7 or less. Inside a crontab, % must be escaped:
0 9 * * 1 [ "$(date +\%d)" -le 07 ] && /path/to/job
Trap 3: steps restart every hour
*/45 * * * * reads like "every 45 minutes". Steps restart each hour, so it runs at :00 and :45: 45 minutes apart, then 15. An even 45-minute interval cannot be written as one cron line. If you need a real interval, EventBridge has rate(45 minutes) and systemd has OnUnitActiveSec=45min.
Trap 4: 09:00 in which time zone?
GitHub Actions schedules run in UTC unless you add a timezone: key with an IANA name next to cron. Classic EventBridge rules always run in UTC; EventBridge Scheduler takes a time zone. A UTC 09:00 is 10:00 in Berlin in winter and 11:00 in summer.
On Kubernetes, set spec.timeZone (for example Europe/Berlin) on the CronJob to keep 09:00 local all year.
Daylight saving has one more edge: in a few zones (America/Santiago, America/Havana, Asia/Beirut, Africa/Cairo, the Azores) clocks spring forward at midnight, so 00:00 does not exist that day. crontab and Kubernetes skip a 0 0 * * * run on that date.
Falling back is the mirror image: 01:30 happens twice that night, and crontab, Kubernetes and GitHub Actions run a job scheduled then twice. (Thanks to @smtahosin in the comments.)
Trap 5: small syntax differences
- crontab accepts
7for Sunday; a Kubernetes CronJob rejects it. Use0orSUN. - cron starts the next run whether or not the last one finished. In crontab wrap the command in
flock -n; on Kubernetes setconcurrencyPolicy: Forbid(skip the new run) orReplace(stop the old one).
A checklist before you ship a schedule
- Use day and month names, not numbers.
- Write down which time zone the scheduler uses, and set it explicitly where you can.
- Look at the next 10 run times, not just the expression.
- If both day fields are set, check whether you meant OR.
- Decide what happens when a run is still going when the next one is due.
Tools
I kept making these mistakes, so I built a converter that translates a schedule between all six and checks each translation run by run against the original. It says so when a schedule cannot be written in one line on the target: https://opspane.dev/cron/translate/
There are also reference pages for common schedules (every 15 minutes, weekdays at 9, first of the month…) with the same schedule on all six platforms: https://opspane.dev/cron/schedules/
Everything runs in the browser. Which of these has bitten you, and is there one I missed?
Top comments (5)
Trap 3 is the one that has got me, */45 looks like a good interval unless you pay attention to the timestamps. One thing I would have wanted to see added to your list is the falling back part of DST. You have already pointed out that springing forward results in a missed run, but the falling back can also result in running the same local hour twice, and the job running at 1am with no idempotency check happily executes twice. Kubernetes startingDeadlineSeconds is another one that keeps coming back to my mind since it decides whether a run that was missed due to an outage fires or is intentionally skipped. On the time zone aware platforms, does your converter show the next runs across a DST boundary?
Thanks, this is a great addition. Trap 3 catches a lot of people for exactly the reason you describe: the expression looks right and only the timestamps give it away.
You're right about falling back, and it deserves its own line. The six platforms don't even agree on it:
So the same "30 1 * * *" can double-fire on one platform and not on another. An idempotency check is the only fix that holds everywhere. The simplest version is to record the date of the last successful run and exit if it already ran today. I've added a line about it to Trap 4.
On startingDeadlineSeconds: agreed, and it has a trap of its own. Without it, a controller that was down for a while counts every missed schedule since the last run; past 100 it only starts the most recent one. Values under 10 seconds can stop the job from ever starting, because the controller only checks every 10 seconds. The systemd equivalent is Persistent=true, which runs a missed timer once after downtime instead of skipping it.
To your question: yes, with a caveat. The explainer takes a time zone, lists the next runs in that zone and in UTC, and warns with the exact date when an hour is skipped or repeated: opspane.dev/cron/explainer/
The converter notes the per-platform DST differences but doesn't list runs per zone yet.
date-check guard's going in my jobs this week Thanh lol, duplicate 1:30am emails taught me that one. twice on crontab, once on systemd... no wonder it felt haunted. thanks for the Trap 4 line :D
"Haunted" is exactly how DST bugs feel: twice a year, never when you're looking. Good luck with the guard!
thanks Thanh, guard's going in tomorrow morning before I forget lol. gonna test it on the 1:30am job first, that one's still my nemesis xD