3

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.

0

1 Answer 1

5
+100

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:

[Timer]
Unit=test.service
AccuracySec=1s
OnActiveSec=5s
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

OnUnitActiveSec=78m

or

OnUnitActiveSec=4680

You must log in to answer this question.