I’ve spent some time trying to figure out how to map our syntax to whatever systemd.timer(5)
and systemd.time(7)
support. I think we have a conceptual problem and only a subset of the supported syntax & functionality can mapped to systemd.
The main problem I see is that our syntax describes either discrete time points (eg. mon,14:00
) or a time spans (eg. mon-wed,12:00-14:00
). Then intention is that the action associated with the timer happens just once in the span (sub-span). For instance
-
mon,14:00
(actuallymon,14:00-14:00
) - the event happens once on Mondays at 14:00 -
mon,12:00-14:00
- once on Mondays between 12:00 and 14:10 -
mon-wed,12:00-14:00
- once on between 12:00 and 14:00 on Monday, Tuesday and Wednesday -
12:00-14:00/2
(logically12:00-13:00,13:00-14:00
) once between 12:00 and 13:00, and again between 13:00 and 14:10 -
wed2
- once on the 2nd Wednesday, at 0:00 -
23:00-01:00
- daily, once between 23:00 and 01:00 the next day -
23:00~01:00
- daily, once at randomly chosen time between 23:00 and 01:00 the next day -
11:00-12:00
- if the event didn’t happen before and it’s 11:23, the even will happen now, next one on the next day at 11:00
For comparison, systemd.time
syntax describes discrete time points only (assuming that we use OnCalendar=
). The action happens on each event. To illustrate (note I’m trying to use similar times as above):
-
Mon 14:00
- the event happens on Mondays at 14:10 -
Mon 12..14:00:00
- the event happens on Mondays at 12:00, 13:00, 14:00 -
Mon 12..13:*:00
- there’s a an event each minute between 12:00 and 13:59 on Mondays -
Mon 12..14/2:00:00
- even at 12:00 and another one at 14:00 on Mondays -
Wed *-8..14
- once on the 2nd Wednesday, at 0:00 -
23..01:00:00
- does not parse -
23:00
&RandomizedDelaySec=7200
, at 23:00 + randomized delay between 0 and 2h -
11..12:00:00
- if the event didn’t happen before and it’s 11:23, the even will happen at 12:00, next one on the next day at 11:00
I looked at the other [Timer]
options, such as OnActiveSec
, OnUnitActiveSec
, but those don’t seem to be usable when mapping. OnActiveSec
can be used to specify the delay from the last activation. OnUnitActiveSec
is the delay from when the unit activated by the timer was last activated.
My feeling is that we will have to limit the timer services to specify timers that can be mapped to discrete events.
In other words:
- support only single hour:minute (with exception, read on)
- day spans though. spans wrapping around a week (actually all day spans) will be mapped to a list of days, eg.
fri-mon
->Fri,Sat,Sun,Mon
. - randomized time range, eg:
12:23~14:00
(I think it’s useful if the action would result in poking some remote machine)
Let me know your thoughts.