Systemd Service – Timer OnCalendar Every Minute Ending with 5

cronsystemd-service

With OnCalendar systemd timer i can create something like this to run every 5 minutes.

OnCalendar=*:0/5

Is it possible to run it at every minute ending at 5 (00:05, 00:15, 00:25…) only?

And/or at every minute ending with a 0 (00:00, 00:10, 00:20…) only?

Main goal is to have a timer on 2 server, so each one runs at spare times; in case one fails, the other will at least run every 10 minutes (instead of 5).

Best Answer

Solution:

OnCalendar=*:5/10

which is equivalent to *:5,15,25,35,45,55.

To be sure of the result, use something like:

systemd-analyze calendar --iterations=8 '*:5/10' | grep Iter
       Iter. #2: Sun 2022-02-20 00:25:00 CET
       Iter. #3: Sun 2022-02-20 00:35:00 CET
       Iter. #4: Sun 2022-02-20 00:45:00 CET
       Iter. #5: Sun 2022-02-20 00:55:00 CET
       Iter. #6: Sun 2022-02-20 01:05:00 CET
       Iter. #7: Sun 2022-02-20 01:15:00 CET
       Iter. #8: Sun 2022-02-20 01:25:00 CET