I have an existing systemctl target that was originally (by default installation) scheduled to run everyday, almost continuosly with just a pause of 30 seconds between the end and beginning of each run, i.e. with its default /usr/lib/systemd/system/my-unit.timer being:
[Unit]
Description=My Unit description
[Timer]
OnActiveSec=0
OnUnitInactiveSec=30s
Unit=my-unit.target
[Install]
WantedBy=timers.target
Now I got a requirement to restrict the running time window to a range of hours every day. I've had a look around and thought that I could modify the scheduling without altering the existing target/timer, by using the command:
systemctl edit my-unit.timer
which would automatically create an override timer conf in
/etc/systemd/system/my-unit.timer.d/override.conf
I have for example written the following systemd timer associated to a namesake systemd target:
[Timer]
# Disable the default timer
OnUnitInactiveSec=
OnCalendar=*-*-* 17,18:*:00
This, in my understanding, should run everyday, every minute from 17:00 to 18:59. The problem is that it actually runs once the first time I restart the timer. It will start at the expected next minute turn, but won't reschedule the following ones:
NEXT LEFT LAST PASSED UNIT ACTIVATES
Fri 2021-03-12 17:20:00 CET 1min 4s ago Fri 2021-03-12 17:20:01 CET 1min 2s ago
this was an example of me restarting the timer slightly before 17:20. The target did run at 17:20 as expected, but then the NEXT didn't update. And it won't until I manually restart the timer. I would pass it through the:
systemd-analyze calendar
command and show its output here if possible, but the calendar command was not available for systemd-analyze in Ubuntu 16.04 yet.
What am I doing or what did I understand wrong ?
As a side question, in case I wanted to use the same "30secs after last run" pattern but limit it to a few hours a day, is it possible to combine monotonic timer specifications (like the above OnUnitInactiveSec) with OnCalendar to say "run on these monotonic pattern, but only during this calendar time-range" ?