NOTE: Do not submit anything other than bug reports or RFEs via the issue tracker!
v231
NOTE: Do not submit bug reports about anything but the two most recently released systemd versions upstream!
CoreOS
Monotonic timers using
OnActiveSeckeep triggering their.serviceunit till infinity
Monotonic timers using
OnActiveSeconly trigger their.serviceunit once and then never trigger again
>
Create timertest.service:
[Unit]
Description=TimerTest
[Service]
Type=simple
ExecStart=/usr/bin/echo "test"
Create timertest.timer:
[Unit]
Description=Runs timertest every 10s
[Timer]
OnActiveSec=20s
Then start the timer:
systemctl daemon-reload
systemctl start timertest.timer
# And watch how the timer triggers once and then never triggers again/shows N/A for NEXT and LEFT
watch -n2 'systemctl list-timers --all'
# Output after it triggering the first time below
NEXT LEFT LAST PASSED UNIT ACTIVATES
n/a n/a Fri 2016-11-04 13:46:56 CET 8min ago timertest.timer timertest.service
The behavior is correct and documented. You probably want OnUnitActiveSec.
The behavior is correct and documented. You probably want OnUnitActiveSec.
@arvidjaar do you mean these docs? https://www.freedesktop.org/software/systemd/man/systemd.timer.html
I can't find any mention of this behaviour there. The only relevant item seems to be this:
OnActiveSec= defines a timer relative to the moment the timer itself is activated.
...
OnUnitActiveSec= defines a timer relative to when the unit the timer is activating was last activated.
Which doesn't mention any other differences between OnActiveSec and OnUnitActiveSec apart from the different definition of the starting moment.
If this isn't supposed to work, then what purpose does OnActiveSec actually serve?
This is really just a misunderstanding. OnActiveSec= defines a timer that elapses a certain amount of time the timer unit itself is actviated. i.e. it defines exactly one wakeup, after you issue "systemctl start foo.timer". It is not repeated then, it's a singular event. If you want multiple, repetitive arguments, you need to combine it with another stanza, for example OnUnitActiveSec=. That stanza will trigger a certain amount of time after the unit the timer unit is supposed to activate has been activated. This of course is repetitive, but only applies to units that have been activated at least once. Hence. OnActiveSec= is for the _first_ trigger of the timer unit, and OnUnitActiveSec= may then be used for all subsequent starts.
I hope this makes sense?
Most helpful comment
This is really just a misunderstanding. OnActiveSec= defines a timer that elapses a certain amount of time the timer unit itself is actviated. i.e. it defines exactly one wakeup, after you issue "systemctl start foo.timer". It is not repeated then, it's a singular event. If you want multiple, repetitive arguments, you need to combine it with another stanza, for example OnUnitActiveSec=. That stanza will trigger a certain amount of time after the unit the timer unit is supposed to activate has been activated. This of course is repetitive, but only applies to units that have been activated at least once. Hence. OnActiveSec= is for the _first_ trigger of the timer unit, and OnUnitActiveSec= may then be used for all subsequent starts.
I hope this makes sense?