Edge cases

Cron and daylight saving time.

Twice a year, cron jobs scheduled in DST-observing timezones can either be skipped entirely (spring forward) or fire twice (fall back). This guide explains exactly what cron does, when it bites, and the three strategies that actually work.

What happens at DST transitions

Cron schedules jobs by wall-clock time in the system's timezone. When DST kicks in, the wall clock jumps, usually forward 1 hour in spring and back 1 hour in fall. This creates two pathological windows:

TransitionEffectExample time that disappears or repeats
Spring forward (Mar in US)1 AM-3 AM hour disappears2:30 AM never occurs that day
Fall back (Nov in US)1 AM-2 AM hour repeats1:30 AM occurs twice

If your cron job is scheduled within these windows, you have a problem.

Spring forward: skipped runs

Imagine your job: 30 2 * * *: every day at 2:30 AM. On the morning the clocks spring forward, the time goes:

1:58 AM → 1:59 AM → 3:00 AM

2:30 AM never happens, and what your job does depends on the scheduler. Linux cron (Debian, Ubuntu and cronie on RHEL/Fedora) runs a fixed-time job like this one right after the jump, at about 3:00 AM. systemd timers, Kubernetes CronJobs and AWS EventBridge Scheduler skip it for that day, and GitHub Actions moves it to 3:00 AM. A skipped daily backup is one lost run; a skipped billing reconciliation can cost money.

Check your own schedule and time zone with the cron daylight saving time checker: it lists every clock change in the next 12 months and what each scheduler does with each run.

How to detect it

Look at the log on Monday after a spring-forward Sunday. If your "every night at 2:30 AM" job has entries every day except Sunday's, this is likely the cause.

Fall back: duplicated runs

On the fall-back morning, the time goes:

1:58 AM (DST) → 1:59 AM (DST) → 1:00 AM (standard) → 1:01 AM (standard) → ... → 2:00 AM

The 1 AM-2 AM hour repeats, so 1:30 AM happens twice. Linux cron and systemd timers run 30 1 * * * only once. A Kubernetes CronJob with a time zone runs it twice, at 1:30 AM DST and again at 1:30 AM standard time. Linux cron also runs jobs with * in the minute or hour field, such as */15 * * * *, in both passes of the repeated hour.

Why this is worse than skipping

A skipped run is one missed execution. A duplicated run can cause:

  • Duplicate emails sent
  • Duplicate billing entries
  • Race conditions if the previous run hadn't finished
  • Corrupted data if the job isn't idempotent

Three strategies that work

Strategy 1: Run in UTC

UTC doesn't observe DST. If your system's timezone is UTC, the issue can never occur. Most cloud servers default to UTC for exactly this reason.

Trade-off: your 0 9 * * 1-5 will fire at 9 AM UTC, which shifts in local terms when DST changes. If you need "9 AM Pacific time always," you can't have that from a UTC server without adjusting the cron twice a year. Choose your poison: schedule drift or duplicated/missed runs.

Strategy 2: Avoid the DST window entirely

Schedule jobs outside the dangerous hours. For US-style DST (1-3 AM), schedule at 4 AM or later. Most batch jobs don't care whether they run at 2 AM or 4 AM:

# Risky:
30 2 * * *    /path/to/nightly.sh

# Safe:
30 4 * * *    /path/to/nightly.sh

Strategy 3: Make the job idempotent + use anacron-style tracking

If you can't avoid the DST window, design your job to be safe under both skipping and duplication:

  • Idempotent: running the job twice has the same effect as running it once. Use database transactions, "INSERT ... ON CONFLICT IGNORE", file locks, or a sentinel marker.
  • Self-tracking: check the last successful run timestamp and skip if it's too recent (within 30 minutes, say).
#!/bin/bash
LOCK=/var/run/nightly.lock
if [ -f "$LOCK" ] && [ $(( $(date +%s) - $(stat -c %Y "$LOCK") )) -lt 1800 ]; then
  exit 0   # Ran within the last 30 minutes; skip
fi
touch "$LOCK"
# ... actual work here ...

How each platform handles it

Linux cron (Debian, Ubuntu, cronie)

Debian/Ubuntu cron and cronie treat two kinds of job differently. A job at a fixed time (no * at the start of the minute or hour field) that falls in the lost hour runs right after the jump; in the repeated hour it runs only once. A job with * at the start of the minute or hour field (for example */15 * * * *), or @hourly, follows the clock: it has no runs in the lost hour and runs in both passes of the repeated hour. This is described in Debian's cron(8) and implemented in the main loop of cronie's cron.c. Clock changes of 3 hours or more are treated as a clock correction, not daylight saving time.

But: this only works if the cron daemon is running across the transition. If you restart the host during the transition, all bets are off.

systemd timers

A time the clock skips is skipped, and a repeated time runs once, on the first pass (checked with systemd-analyze 255). Because the skipped time is never a scheduled run, Persistent=true has nothing to catch up; it only catches up runs missed while the machine was off. To leave DST out entirely, put a zone at the end of the expression: OnCalendar=*-*-* 02:30:00 UTC. See the cron to systemd timer converter.

Kubernetes CronJob

Without .spec.timeZone, schedules are read in the kube-controller-manager's local time zone, which is UTC on most clusters. .spec.timeZone (stable since Kubernetes 1.27) lets you pick a zone. With a DST zone, the controller's cron library (robfig/cron v3) skips times in the lost hour and runs times in the repeated hour twice, fixed-time jobs included. That is different from Linux cron, so a job that is safe in a crontab can run twice in Kubernetes.

AWS EventBridge

EventBridge rules always use UTC, so DST never skips or repeats a run. EventBridge Scheduler lets you set a time zone; AWS documents that a time that does not exist in spring is skipped and a repeated time in autumn runs once.

GitHub Actions

Schedules run in UTC unless you add timezone: next to the cron line. With a time zone, GitHub documents that a time in the skipped hour moves to the next valid time (2:30 AM runs at 3:00 AM). GitHub does not document what happens in the repeated hour.

Quartz (Java)

Configurable. The trigger's TimeZone property controls DST behavior. By default it follows the JVM's default timezone, which inherits from the OS.

Recommendation

For new jobs: run in UTC and adjust the cron expression to UTC equivalents. This is the only foolproof approach.

For existing jobs in a DST-observing timezone: move them out of the 1-3 AM window. Schedule for 4 AM or 5 AM instead. The few hours of "drift" between standard time and DST is rarely meaningful for batch work.

If you genuinely need the schedule to track local time precisely (e.g., business-hour user-facing jobs), use a real scheduler with built-in timezone support: systemd timers, AWS EventBridge Scheduler, or GCP Cloud Scheduler.