Plainnotes

cron and daylight saving: twice a year of surprises

2024-02-13 · 2 min readSystems

In a zone with daylight saving, a job at 0 2 * * * breaks twice a year:

  • Spring forward: 02:00–03:00 does not exist, so the job is skipped.
  • Fall back: 01:00–02:00 occurs twice, so the job may run twice.

In Asia/Shanghai there is no DST, but cloud hosts often default to UTC while the business thinks in local time.

Check timedatectl before writing a schedule. Teams spanning zones are better off scheduling in UTC and converting at the display layer.

If a job must follow local time and must not be skipped, systemd timers can carry the zone explicitly: OnCalendar=*-*-* 02:00:00 Asia/Shanghai.