systemd timer misses periodic jobs after resume — clock jumps forward on resume when host uses TSC as RTC
Environment
Ubuntu 22.04 laptop running systemd timers for backups and ACME renewals. Host suspends to RAM (S3) overnight. After resume, some timers are not triggered for up to several minutes and ACME renewal fails.
Symptoms
Jobs scheduled via systemd timers (OnCalendar and Persistent timers) either do not run at their expected time after resume or run with a large delay. systemd journal shows 'Stepped system clock forward by 1min 23s' and several timers show 'missed' entries. timedatectl shows that RTC and system time differ after resume.
Observations
dmesg shows platform resume then 'kvmclock: Syncing TSC' messages on VMs; host uses TSC as clocksource. systemd-timesyncd reports a large step adjustment shortly after resume. Some timers with AccuracySec=1min are not scheduled until systemd steps the clock. Timers with Persistent=true that should have run during sleep do not show RunOnCalender entries until after timesyncd step.
Already attempted
Swapped clocksource to hpet temporarily (echo hpet > /sys/devices/system/clocksource/clocksource0/current_clocksource) then suspended and resumed — timers fired as expected. Enabled NTP in timesyncd and set NTP server, but step adjustments remain. Upgraded kernel to latest stable; behavior persists.
Question
How to make systemd timers reliably fire immediately after resume without large clock steps, and avoid missed scheduled jobs following suspend/resume cycles?
Verified community troubleshooting
Most cases are caused by the kernel clocksource (TSC) producing a different time after suspend, so switch to a stable clocksource or use a timesync client that slews time. Quick test: sudo sh -c 'echo hpet > /sys/devices/system/clocksource/clocksource0/current_clocksource' then suspend/resume; if timers fire correctly, you can test making that persistent via kernel cmdline (clocksource=hpet) or prefer chrony instead of systemd-timesyncd to avoid large steps. Also ensure critical timers use Persistent=true and consider a small startup script to run missed work on resume. Roll back by removing the cmdline change or switching clocksource back to tsc if it causes regressions (some systems run worse with hpet).
Incident analysis
Most likely causes
Summary
Suggested Fixes
Continue troubleshooting
Related troubles
Matched from the title, description and tags
- Linux52% match
Ubuntu 22.04 LXC container clock jumps forward after host resume, cron misses jobs and ACME renewal fails
Solved1 answer - Virtualization35% match
KVM guests' clocks jump forward minutes after host suspend/resume when host uses TSC as RTC and guests use kvmclock
Open0 answers - Linux26% match
Debian guest clock jumps forward after KVM snapshot restore, causing missed cron jobs and certificate timing errors
Open0 answers - Virtualization22% match
Docker containers lose DNS resolution after laptop resume on Ubuntu 22.04 due to systemd-resolved stub resolver change
Open0 answers - Linux21% match
Ubuntu 22.04 laptop: Docker containers lose DNS after suspend/resume due to systemd-resolved stub resolver race with NetworkManager
Open1 answer