[systemd-devel] Syntax for periodic calendar events (systemd.time)

Lennart Poettering lennart at poettering.net
Wed Sep 4 10:00:52 UTC 2024


On Mi, 04.09.24 08:19, Windl, Ulrich (u.windl at ukr.de) wrote:

> Hi!
>
> When trying to adjust a timer that ran with "OnCalendar=daily" to a
> period like 15 minutes, I made a series of mistakes (after having
> read systemd.time), so I can make a number of suggestions for
> improvement:
>
> First I had tried to put the specification inside double-quotes as
> the string contained a space. The result was a syntax error ("Failed
> to parse calendar specification"). Couldn't systemd just tolerate
> the unneeded double-quotes?

I am not convinced this is necessary. We are not a shell...

>
> I had succeeded for 30 minutes, listing "00,30" in the minutes
> field, but when I wanted to change it to 5 minutes, I thought the
> list would become too ugly (i.e.: long), so I tried the "slash
> syntax".  Unfortunately "*-*-* *:00/5m:00" and "*-*-* *:/5m:00"
> weren't accepted, just as plain "/5m" was not. Couldn't the first
> two be accepted, even though the minutes are redundant? And for the
> last one: Why can't it be accepted; it would look so nice and clean,
> and (IMHO) it's unambiguous, too.

well, if you allow the time unit, then it should have a purpose. But
what would you make of an expression such as "*:0/25s:*" even?

> The eventual syntax I used was "*-*-* *:00/5:00" (for "every 5
> minutes"). Isn't it "more ugly then needed"?

You can wrote this as "*:0/5" btw.

Ugliness is in the eye of the beholder. generally, I am not too much
of a fan of overly redundant syntaxes, i.e. allowing redundant syntax
that bring no major benefit in expressivity or brevity or so. I think
neither of your suggestions here really bring much to the table in
that regard?

Btw, if you just want to start some timer every 5min then there's
little point in using calendar time. you could instead use monotonic
time, i.e. OnActiveSec=5min + OnUnitActiveSec=5min

Lennart

--
Lennart Poettering, Berlin


More information about the systemd-devel mailing list