The Clocks Went Back and Your Cron Jobs Did Not Notice
Photo: ZemplinTemplar, CC BY-SA 4.0, via Wikimedia Commons
On 25 October 2026 the UK fell back to GMT. Most of the country got an extra hour in bed. Somewhere in a rack, a scheduled job got an extra hour of work, or lost one entirely, and nobody noticed until the month-end numbers came out short.
British Summer Time is a twice-yearly reminder that time is a political construct with an API. Your database, your container and your crontab each hold a slightly different opinion about what 2am means, and the disagreement only surfaces twice a year, usually at the worst possible moment.
The bug that never gets a ticket
The classic failure is a job scheduled for 01:30. On the autumn change, 01:30 happens twice. On the spring change, it does not happen at all. Nothing throws. No alert fires. The job either runs twice — double-charging a card, double-emailing a customer, double-posting a journal — or silently skips a day. Either way, the first person to notice is usually the one reconciling a spreadsheet on a Monday morning.
Billing runs, payroll exports, direct debit collection files, nightly reconciliations, report snapshots and backup rotations are all candidates. So are the smaller embarrassments: the renewal reminder that goes out twice, or the one that never goes out at all.
The uncomfortable truth is that these are not really timezone bugs. They are missing-idempotency bugs wearing a timezone costume.
Store UTC, display local, and mean it
If you take one thing away: store instants in UTC, store the timezone as data where it matters, and convert at the edges. A timestamp column full of local times is a permanent liability, because it is ambiguous for one hour a year and it cannot tell you which hour it meant.
A few practical points that catch people out:
- Use the tz database, not a fixed offset.
Europe/Londonis a rule;GMT+1is a guess that will be wrong for half the year. - Keep tzdata current. Base images pin an old release and quietly go stale after a government changes a rule somewhere in the world. Rebuild regularly.
- Be explicit in your runtime. In Java,
ZonedDateTimewithZoneId.of("Europe/London"). In Python,zoneinforather than a hand-rolled offset. In JavaScript,Intl.DateTimeFormatwith a timeZone option rather than arithmetic ongetTimezoneOffset(). - Store the business date alongside the instant. A payroll run is not just a moment; it is a period, and the period is what you deduplicate against.
Cron is not as clever as you think
Cron runs against the system timezone. Most containers ship with UTC. So a job declared as 0 2 * * * fires at 02:00 UTC, which is 03:00 in British Summer Time and 02:00 in GMT. That is a one-hour drift for roughly seven months of the year, and nobody scheduled it.
Worse, on a host set to Europe/London, a job at 01:30 on the autumn change can fire twice, and a job at 01:30 on the spring change can be skipped entirely, depending on the daemon.
Two workable approaches:
- Run cron in UTC and do the local reasoning in the application. The scheduler wakes up hourly or daily; the application decides whether the current instant falls inside the intended local window and whether this business period has already been processed.
- Use a scheduler with explicit timezone support and an explicit DST policy. Most managed schedulers let you say what should happen to a job that lands in a skipped or repeated hour. Read that setting rather than assuming it.
Either way, the decision about what to do in the ambiguous hour should be a written policy, not an emergent property of whichever box the job ran on.
Idempotency is the real fix
A robust month-end job looks less like a timer and more like a ledger. Before doing anything, it asks: has this period already been processed? Then it writes a record saying so, ideally with a unique constraint on the business period so a race condition cannot cheat you.
In practice:
- Give every run a deterministic key derived from the period, not from the wall clock.
- Wrap the work and the record in one transaction where possible.
- Make the underlying operations upserts rather than blind inserts.
- Log the resolved timezone and the business date with every run, so the next person has something to go on.
This is worth doing anyway. Servers restart, deploys interrupt jobs, and people click Run Now. The clock change is just the occasion when it becomes visible.
Testing it without waiting six months
You can freeze or shift time in tests. libfaketime on Linux, freezegun in Python, a controllable Clock bean in Java, or injected time providers in anything. Write cases for:
- 2026-10-25T00:30Z and 2026-10-25T01:30Z — the hour that happens twice.
- 2027-03-28T00:30Z — inside the hour that does not exist.
- A month-end that falls on the day after a clock change.
If a test only asserts that a job ran, it will pass happily while doing the wrong thing twice.
A checklist for the March change
- Every scheduled job has a named timezone and a stated DST policy.
- Server and container timezones are known, documented and consistent.
- Business-critical jobs are idempotent against a business period.
- Alerts fire on missing runs, not just on failures.
- Reports state the timezone they were generated in.
- Nobody deploys on the Sunday morning in question.
The clocks go forward again on 28 March 2027. That is roughly twenty weeks to find the job that has been quietly double-running since October. Worth a look.