--- id: b33e2316-6313-4ed9-b95a-3a469b820101 type: insight title: "Systemd OnCalendar=weekly and OnCalendar=daily fire simultaneously on Sundays/Mondays - always stagger shared-state timers" tags: [systemd, timer, gotcha, race-condition, cognitive-memory, scheduling] importance: 0.5 confidence: 0.8 created: "2026-02-20T06:47:13.739265+00:00" updated: "2026-02-20T06:47:17.701728+00:00" relations: - target: 59268a95-4712-48b4-bccb-6171c7885301 type: CAUSES direction: incoming strength: 0.9 edge_id: 6f7d12e4-b494-4aea-9be9-f43a5492719c --- # Systemd Timer Collision Gotcha ## The Problem `OnCalendar=weekly` resolves to `Mon *-*-* 00:00:00` (Monday midnight). If another timer uses `OnCalendar=daily`, both fire at the same second on Monday midnight. Any two services that share a state file will race each other. ## Consequence Silent data loss. If both services do read-modify-write on the same JSON file without atomic locking, one will clobber the other's changes. If the loser's write also corrupts the file, a silent `JSONDecodeError` catch can return an empty dict, permanently losing all state. ## Fix Pattern Always stagger timers that access shared resources by at least an hour: ```ini # Instead of: OnCalendar=weekly # Use: OnCalendar=Sun *-*-* 02:00:00 ``` This avoids the Monday midnight collision and gives the daily timer time to finish first. ## General Rule Never schedule two services that share state files at the same `OnCalendar` interval without explicit offset staggering.