I wanted to run a service that runs once per day (exact time of day is not important right now). My interpretation of
OnUnitInactiveSec= defines a timer relative to when the unit the timer is activating was last deactivated.
is that there will be a specified pause between the unit being run (and thus inactive again) and the next invocation.
My units are defined like this:
Service:
[Unit]
Description=User Check (%i)
Documentation=man:[email protected] man:user-check(8)
After=multi-user.target
AssertPathExists=/etc/user-check/common.conf
AssertPathExists=/etc/user-check/%i.conf
[Service]
Type=simple
EnvironmentFile=/etc/user-check/common.conf
EnvironmentFile=/etc/user-check/%i.conf
ExecStart=/usr/bin/user-check \
$CHECK_SELECTION --notification-template=${NOTIFICATION_TEMPLATE} \
$OTHER_OPTIONS
RestartPreventExitStatus=1 2
Timer:
[Unit]
Description=User Check (%i) Timer
Documentation=man:[email protected] man:[email protected]
AssertPathExists=/etc/user-check/%i.conf
[Timer]
OnUnitInactiveSec=1day
Unit=user-check@%i.service
[Install]
WantedBy=timers.target
The timer is both, enabled and started (actually I have four instances). Like this:
# systemctl status [email protected]
● [email protected] - User Check (pw-expiration) Timer
Loaded: loaded (/usr/lib/systemd/system/[email protected]; enabled; vendor preset: disabled)
Active: active (elapsed) since Fri 2024-06-28 13:55:28 CEST; 2 days ago
Docs: man:[email protected]
man:[email protected]
Jun 28 13:55:28 v04 systemd[1]: Stopped User Check (pw-expiration...
Jun 28 13:55:28 v04 systemd[1]: Stopping User Check (pw-expiratio...
Jun 28 13:55:28 v04 systemd[1]: Started User Check (pw-expiration...
The service unit had been executed once when the timer was started. I was expecting the timer to fire over the weekend, but it did not.
What's wrong? Is there a "timer checklist"?
I also tried an override using OnUnitActiveSec=15min
, but 55 minutes passed since the unit had been active.
When trying OnCalendar=hourly
the last activation was an hour ago, but still nothing happened.
It seems "systemctl edit" still requires a "reload" of the unit; doing so seemed to enable the calendar timer, but the original timers just don't work (see the n/a
).
The output of systemctl list-timers
is:
# systemctl list-timers
NEXT LEFT LAST PASSED UNIT
Mon 2024-07-01 15:00:00 CEST 35min left n/a n/a user-check@auth-fail.
n/a n/a n/a n/a user-check@grace-logi
n/a n/a n/a n/a user-check@pw-expirat