Made on Earth Donate

The cron job that ran twice (or never) when the clocks changed, and the day-of-week trap

14 November 2026 · 11 min read · by Varun Agrawal

The tool this post is aboutCron Expression Explainer & Next Run TimesTurn a crontab line into plain English and list its next runs in the server’s time zone and yours, with the runs daylight saving skips or doubles flagged.

The backup ran twice. Or the invoice run didn’t happen. Or the report that always lands at 02:30 arrived at 03:00, once, on a Sunday in March, and nobody could reproduce it. The crontab hadn’t changed in years, the server was fine, and the logs showed cron doing something nobody asked it to do.

Two things cause most of these mysteries. The first is the night the clocks change, when some times of day don’t exist and others happen twice, and cron has to decide what a job set for one of them should do. The second is an old rule about the two day fields that turns “Friday the 13th” into “every Friday, and every 13th”. Neither is a bug. Both are written into cron’s source code and have been for decades, and both are easy to miss when you read a crontab line by eye.

This post walks through both with real dates, computed with the same code as the Cron Expression Explainer, which reads a crontab line, lists its next runs in the server’s time zone and yours, and flags every run that a clock change moves, doubles or drops.

A crontab line, read the way cron reads it

A crontab entry has five time fields and then the command:

30 2 * * 1-5  /usr/local/bin/backup

Minute 30, hour 2, any day of the month, any month, Monday to Friday. Each field takes a number, a range (1-5), a list (1,15), * for every value, or a step: */15 means every 15th value from the start of the field, 5-55/10 every 10th value from 5 to 55. Months and weekdays can be names, but only their first three letters: mon-fri works, Monday is an error. Sunday is both 0 and 7.

The details that trip people up are small. A step needs * or a range in front of it, so 5/10, which Quartz and Spring read as “from 5, every 10”, makes Linux cron reject the line. Steps start again at the beginning of the field: */7 in the minute field runs at :00, :07, :14 and so on to :56, then at :00 of the next hour, only four minutes later. 0 12 31 * * doesn’t run on the last day of every month; it skips February, April, June, September and November entirely, because cron never moves a 31st to the 30th. And a percent sign in the command is not a percent sign: cron turns an unescaped % into a new line, so date +%F in a crontab breaks unless you write \%.

Underneath the syntax, the daemon matters. Most Linux servers run one of two descendants of Paul Vixie’s cron: cronie (Fedora, RHEL, CentOS, Rocky, Alma, Arch, openSUSE) or Debian’s cron (Debian, Ubuntu). They read schedules the same way and share the logic that matters on daylight-saving nights. The examples below follow cronie’s source, src/cron.c and src/entry.c.

The night 02:30 doesn’t exist

In most of Europe, daylight saving starts on the last Sunday in March. In Berlin in 2027 that is 28 March: at 02:00 local time the clock jumps straight to 03:00. Between 02:00 and 02:59 there is no time at all. The United States does the same on the second Sunday in March, also at 02:00 local time.

Now take a server whose clock is set to Europe/Berlin and a job that runs at 02:30 every night:

30 2 * * *  /usr/local/bin/nightly-export

You might expect it to skip that night: there is no 02:30 to match. cronie does something else. It wakes up every minute and compares the clock with the last minute it dealt with. At what was 01:59 it handled 01:59; a minute later the clock says 03:00. That’s a jump of 61 minutes. The source sorts jumps like this one, forward by more than five minutes and up to three hours, into a case its comment calls “DST begins”, and does two things:

  • Wildcard jobs run for the new minute only. A wildcard job, in cronie’s terms, is one whose minute or hour field starts with *: */15 * * * *, 30 * * * *, @hourly.
  • Fixed-time jobs, everything else, run once for every skipped minute they would have matched, straight away.

Here is what the explainer lists for that job and that night:

ScheduleRunIn UTCWhat happened
30 2 * * *Sun 28 Mar 2027 03:00 CEST01:0002:30 didn’t exist; run at 03:00, right after the jump
Mon 29 Mar 2027 02:30 CEST00:30back to normal

That’s the report that arrived at 03:00 once a year. Nothing was wrong; cron made up the missed run as soon as it could.

A wildcard job is treated the other way. */15 * * * * on the same server and the same night runs at 01:45 CET and then at 03:00 CEST, 03:15, 03:30. The four runs at 02:00, 02:15, 02:30 and 02:45 simply don’t happen. The logic is sensible: a job that runs every quarter of an hour can afford to miss an hour that didn’t exist, and running it four times in a row at 03:00 would be worse.

The surprise is how cronie decides which kind a job is. It looks only at the first character of the minute and hour fields. 0 * * * * is a wildcard job. 0 0-23 * * * runs at exactly the same times on every other night of the year, but its hour field starts with a digit, so it’s a fixed-time job. On 28 March 2027 the first runs at 01:00 CET, 03:00 CEST and 04:00 CEST. The second runs at 01:00, then twice at 03:00 CEST: once for the missing 02:00, caught up, and once for 03:00 itself. Two schedules that look interchangeable behave differently once a year.

Several fixed times in the gap all catch up, one after another. 0,15,30,45 2 * * * runs four times at 03:00. cronie pauses ten seconds between minutes that started jobs while it catches up, so in practice they come a few seconds apart.

The night 02:30 happens twice

In autumn the clock goes back. In Berlin on 31 October 2027, at 03:00 CEST the clock returns to 02:00 CET, and the hour from 02:00 to 02:59 happens twice, an hour apart in real time. In New York on 7 November 2027 it’s 01:00 to 01:59 that repeats.

cronie sees the clock go backwards by 59 minutes. Its comment for this case says “DST ends”, and the rule is: until the clock catches up with the last minute it handled, run only the wildcard jobs. Fixed-time jobs already ran the first time round and are not repeated.

ScheduleServer zoneRuns on the night
30 2 * * *Europe/BerlinOnce: 02:30 CEST (00:30 UTC). Not again at 02:30 CET.
*/15 * * * *Europe/Berlin02:00, 02:15, 02:30, 02:45 CEST, then 02:00, 02:15, 02:30, 02:45 CET, then 03:00: eight runs in the repeated hour
30 1 * * *America/New_YorkOnce: 01:30 EDT (05:30 UTC)
30 * * * *America/New_YorkTwice: 01:30 EDT and 01:30 EST, an hour apart

So the backup that ran twice was almost certainly a wildcard job. If a job mustn’t run twice, the minute and hour fields need to be plain numbers, or the job needs its own lock (flock -n /run/lock/backup.lock /usr/local/bin/backup is the usual one-liner), which is worth having anyway in case a run takes longer than the gap to the next.

Half-hour changes

Lord Howe Island, off the coast of Australia, moves its clocks by thirty minutes: from 02:00 to 02:30 on the first Sunday in October, and from 02:00 back to 01:30 on the first Sunday in April. cronie’s thresholds are in minutes, not hours, so a thirty-minute jump gets the same treatment as a sixty-minute one. A 15 2 * * * job on a Lord Howe server runs at 02:30 on 3 October 2027, straight after the jump, and at 02:15 again the next night.

More than three hours

A jump of more than three hours in either direction isn’t daylight saving as far as cronie is concerned. It’s someone fixing a wrong clock, and cronie simply carries on from the new time: skipped minutes are lost and repeated minutes run again, for every job.

CRON_TZ, TZ and the server’s zone

Cloud servers usually run on UTC, which never changes its clocks. That makes cron predictable, but it means the 02:30 job runs at 03:30 or 04:30 local time depending on the season. The obvious fix is to tell cron which zone a job is meant for, and here it gets messy.

TZ=Europe/Berlin at the top of a crontab does not do it. It sets the time zone the command sees when it runs; the schedule is still read on the server’s clock. cronie has a separate variable for the schedule, CRON_TZ. Debian and Ubuntu’s cron has no such thing: its man page says it schedules on the system zone only.

With CRON_TZ, cronie checks the job each minute against the other zone’s clock, converting the real time with the system’s time zone database. None of the catch-up logic applies to that zone, because cronie’s own clock never jumped. So on a UTC server:

CRON_TZ=Europe/Berlin
30 2 * * *  /usr/local/bin/nightly-export
  • runs on Saturday 27 March 2027 at 02:30 CET, and next on Monday 29 March at 02:30 CEST. Sunday’s run is lost: Berlin’s clock never shows 02:30 that night, and nothing catches it up.
  • runs twice on Sunday 31 October 2027, at 02:30 CEST and again at 02:30 CET, because the Berlin clock shows 02:30 twice. Being a fixed-time job doesn’t help.

cronie’s source is candid about it: “There will be jobs missed or run twice during the DST change in the job timezone. It is recommended not to schedule any jobs during the hour when the DST changes happen if job-specific timezones are used.” There’s one more wrinkle. While the server’s clock is repeating an hour, cronie runs only wildcard jobs, and that includes CRON_TZ jobs. On a Berlin server, a fixed-time job with CRON_TZ=UTC set for 01:30 UTC falls exactly in Berlin’s repeated hour on the last Sunday in October, and doesn’t run that day.

The same applies, in spirit, to schedulers that only look like cron. GitHub Actions always runs schedules in UTC. A Kubernetes CronJob uses its spec.timeZone, or the controller’s own zone without one, and computes its runs with a different library from cron’s. systemd timers work from the calendar in their own way. If a job’s timing matters on daylight-saving nights, check what your scheduler does rather than assuming it behaves like cron.

Friday the 13th, every Friday

The second classic has nothing to do with clocks. Someone wants a job on Friday the 13th and writes the obvious line:

0 0 13 * 5  /usr/local/bin/spooky-report

The explainer reads it as “At 00:00, on the 13th of the month and on every Friday”, and from mid-November 2026 lists: Fri 20 Nov, Fri 27 Nov, Fri 4 Dec, Fri 11 Dec, Sun 13 Dec, Fri 18 Dec, Fri 25 Dec, Fri 1 Jan, Fri 8 Jan, Wed 13 Jan. Every Friday, plus every 13th whatever day it falls on.

That’s the rule, and it’s old: when both the day-of-month and the day-of-week fields are restricted, a day matches if either matches. The comment in cronie’s source calls it bizarre and adds “like many bizarre things, it’s the standard.” It does make sense for lines like 0 9 1 * 1, “on the 1st, and on Mondays”, but nobody guesses it.

The part that even experienced admins miss is how cron decides that a field is “restricted”: by its first character. If the field starts with *, it counts as unrestricted, and then both fields must match. So:

  • 0 0 */2 * 0: the day-of-month field starts with *, so it’s an AND. It runs on odd-numbered days that are Sundays: 15 Nov, 29 Nov, 13 Dec, 27 Dec 2026, then 3 Jan 2027. Debian’s man page uses almost this exact example to point out that POSIX would read it the other way.
  • 0 0 1-31 * 1: 1-31 covers every day but doesn’t start with *, so it’s an OR, and the job runs every day, not every Monday.

To get a real “Friday the 13th”, keep one day field and test the other in the command: 0 0 13 * * [ "$(date +\%u)" = 5 ] && /usr/local/bin/spooky-report. The same trick covers “the first Monday of the month” (0 9 1-7 * * [ "$(date +\%u)" = 1 ] && …) and “the last day of the month” (0 23 28-31 * * [ "$(date -d tomorrow +\%d)" = 01 ] && …), which cron can’t express on its own. Note the escaped percent signs.

Expressions that only look like cron

Many schedulers borrowed cron’s look and changed its meaning. Pasting their expressions into a crontab, or reading a crontab with their rules in mind, goes wrong quietly:

  • Six fields with seconds first: Quartz, Spring’s @Scheduled, node-cron. 0 30 2 * * MON-FRI in Spring is 30 2 * * MON-FRI in cron. Pasted into a crontab, cron reads the first five fields as minute 0, hour 30 and so on, and rejects the line.
  • Quartz’s ?, L, W and #: “no specific value”, “last”, “nearest weekday”, “nth weekday”. Cron has none of them.
  • Numeric weekdays: Quartz and AWS count 1–7 starting on Sunday, cron 0–7 with both ends Sunday. 2 is Monday in Quartz and Tuesday in cron.
  • AWS EventBridge: cron(0 12 * * ? *), six fields with a year at the end.
  • Jenkins’ H: a minute derived from the job’s name, to spread load.

The explainer names each of these instead of guessing, and where cron can say the same thing it offers the five-field line to open instead.

What the explainer can’t tell you

  • It models cronie. Debian and Ubuntu’s cron agrees on everything above except CRON_TZ, which it ignores. BSD and macOS cron, busybox crond, systemd timers, Kubernetes, GitHub Actions and cloud schedulers each have their own rules, especially on daylight-saving nights.
  • It can’t see your server. You tell it the server’s time zone. If you don’t know, timedatectl or date +%Z on the server will say.
  • Some cronie features can’t be predicted. RANDOM_DELAY starts jobs up to that many minutes late, and the ~ random range picks its value when cron loads the file. The page notes both rather than listing times it can’t know.
  • Rare clock changes. cronie only re-reads the UTC offset when daylight saving starts or ends, so a country changing its standard time is noticed late; the page says so when one is coming, but doesn’t model it. Caught-up runs also trail the jump by a few seconds each, which the page doesn’t show.
  • Load and downtime. A job that’s due while the machine is off or crond is stopped doesn’t run later (anacron exists for that), and a job that’s still running when the next one is due gets started again unless it locks.

Tips for schedules that behave

  1. Keep important jobs out of 01:00–03:00 if the server runs on a zone with daylight saving. That window covers the changes in Europe and North America. Elsewhere the hour differs, and the explainer lists each change for your zone.
  2. Or run servers on UTC and accept that local times shift by an hour twice a year. If people need the local time, the explainer’s second column shows each run in theirs, and the Time Zone Converter helps when planning around it.
  3. Write fixed numbers in the minute and hour fields for jobs that must not run twice, and add a lock for jobs that must never overlap.
  4. Put * in one day field unless you really mean “either day”.
  5. Be careful with CRON_TZ near the changes in its zone, and remember that TZ= doesn’t move the schedule.
  6. Read the line back in words before you save it. Paste it into the Cron Expression Explainer, check the sentence, the next few runs and the daylight-saving list, and send the link to whoever reviews the change.
Try it now, freeCron Expression Explainer & Next Run TimesTurn a crontab line into plain English and list its next runs in the server’s time zone and yours, with the runs daylight saving skips or doubles flagged.

More from the blog

All posts →