systemd timer every 1 hour and X minutes?

I’m looking for a systemd timer to run every 1 hour and 18 minutes but I have this only lead.

systemd-analyze --iterations=3 calendar *:0/18 which is every 18 minutes.

Asked By: deanresin


For a monotonic timer that runs at regular intervals (e.g. every X minutes and Y seconds, every X days and Y minutes etc) you have to define a starting point and a repetition value. This can be accomplished by using two directives in the [Timer] section.
The settings and their their starting points are explained in sytemd.timer man page which also mentions that

Multiple directives may be combined of the same and of different
types, in which case the timer unit will trigger whenever any of the
specified timer expressions elapse. For example, by combining
OnBootSec= and OnUnitActiveSec=, it is possible to define a timer
that elapses in regular intervals and activates a specific service
each time.

So, for a timer that runs every 1 hour and 18 minutes you could use something like:

OnUnitActiveSec=1h 18min

In the above, the initial trigger is

OnActiveSec= Defines a timer relative to the moment the timer unit
itself is activated.

and the repetition is done by

OnUnitActiveSec= Defines a timer relative to when the unit the timer
unit is activating was last activated.

Note that for the time spans provided as arguments you can use any of the time units described in systemd.time man page which means that

OnUnitActiveSec=1h 18min

is the same as



Answered By: don_crissti
Categories: Answers Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.