Interview Prep/Shell Scripting/Scenarios: text processing and scheduling decisions

After a daylight-saving change, a 02:30 job ran twice on one day and not at all on another. How do you prevent this?

IntermediateScenarioScenarios: text processing and scheduling decisions
Answer

Situation read → In time zones with DST, 02:30 does not exist on the spring-forward day and occurs twice on the fall-back day. Cron implementations handle this differently.

What I'd do →

  1. Run servers in UTC (timedatectl set-timezone UTC), which has no DST.
  2. If a local time is a business requirement, use OnCalendar=*-*-* 02:30:00 UTC style explicit zones, or schedule outside the 01:00–03:00 window.
  3. Make the job idempotent (date-stamped outputs, "already done today" check) so a double run is harmless.

Why → DST bugs only appear twice a year, which makes them hard to catch in testing.

Interview tip → Say "servers run in UTC" as a standard, and convert to local time only for display.

All Shell Scripting questions Roadmap: Shell scripting (Bash)

More on Scenarios: text processing and scheduling decisions