Actual Code All articles
Code Quality

The Clocks Went Back and Your Cron Jobs Did Not Notice

Actual Code
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:

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:

  1. 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.
  2. 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:

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:

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

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.

All Articles

Related Articles

Running a Business on a £3 Droplet: An Ode to the Most Fragile Infrastructure in Britain

Running a Business on a £3 Droplet: An Ode to the Most Fragile Infrastructure in Britain

Your Sprint Ceremony Is Costing More Than the Contractor: A Napkin Audit of Meeting Waste

Your Sprint Ceremony Is Costing More Than the Contractor: A Napkin Audit of Meeting Waste

The Only Person Who Understands the Billing System Is Off Sick: A Survival Guide for the One-Man Knowledge Trap

The Only Person Who Understands the Billing System Is Off Sick: A Survival Guide for the One-Man Knowledge Trap