Skip to content

Proposal: Change timer to OnCalendar instead of OnUnitInactiveSec #126

@Danathar

Description

@Danathar

Edit: Cleaned up proposal

The current uupd.timer relies on OnUnitInactiveSec (a monotonic timer). Monotonic timers pause when the system is suspended. This creates a significant issue for "bursty" users who use their laptops for short durations (e.g., 15–30 minutes) and then suspend them for the rest of the day.

For these users, the timer accumulation is effectively paused during suspend. A 6-hour timer threshold might take days or weeks of real-time to actually elapse if the machine is only active for minutes at a time. Consequently, these systems might rarely trigger an automatic update.

I'm proposing to Switch the timer logic from OnUnitInactiveSec (monotonic) to OnCalendar (realtime) with Persistent=true.

  • OnCalendar utilizes the wall clock, meaning the timer "advances" even while the system is suspended.
  • Persistent=true ensures that if the scheduled time (e.g., 04:00) passed while the machine was suspended or powered off, the service triggers immediately upon resume or boot. (Note this is already in the currently deployed timer but I thought it important to emphasize how critical it is with OnCalendar)
  • RandomizedDelaySec Prevents server thundering herd issues.

This configuration below guarantees at least one update attempt per day, regardless of how short the user's sessions are.

[Unit]
Description=Auto Update System Timer For Universal Blue
Wants=network-online.target

[Timer]
# Run daily at 4:00 AM
OnCalendar=*-*-* 04:00:00

# If the system was off/suspended at 4:00 AM, trigger immediately on resume/boot
Persistent=true

# Wait up to 15 minutes after triggering and Spreads the load on update servers (thundering herd protection).
RandomizedDelaySec=15m

[Install]
WantedBy=timers.target

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions