3

There are several good references on systemd timers including this one:

systemd.time

Unfortunately, it still isn't clear to me how to create a timer that will run periodically, but at a specific number of minutes after the top of the hour.

I want to create a timer that runs 30 minutes past the hour, every 2 hours. So it would run at 14:30 (2:30 pm), 16:30, 18:30, 20:30, etc.

I tried several things that did not work, including this:

OnCalendar=*-*-* *00/2:30

And this:

OnCalendar=*-*-* *:00/2:30

I did not find the time specification to produce the desired result.

Also, it does not have to run exactly at that moment, so I was thinking about using:

AccuracySec=5m
  • You should use RandomizedDelaySec=5m instead of AccuracySec for the purpose. – Petri Riihikallio Jan 31 '18 at 9:38
8

Every 2 hours at 30 minutes past the hour should be

OnCalendar=00/2:30
#   iow    hh/r:mm

00/2 - the hh value is 00 and the repetition value r is 2 which means the hh value plus all multiples of the repetition value will be matched (00,02,04..14,16..etc)
30 - the mm value, 30 will match 30 minutes past each hour

I left the date and the seconds out since, per the same man page:

date specification may be omitted, in which case the current day [...] is implied [...]If the second component is not specified, ":00" is assumed.

  • Forgive my ignorance, I am still trying to digest the systemd timer grammar... Would every 4 hours be OnCalendar=00/4:00? – user56041 Mar 28 at 22:02
  • @jww - that is correct. As to your other Q - try to specify Unit=ftc-data.service under [Timer] before (or after) OnCalendar... And btw, you don't enable the service, only the timer. – don_crissti Mar 28 at 23:08
  • Thanks @don. Unit=ftc-data.service did not help. Does crontab still work on new Fedora systems? I'm happy use it to avoid dicking around with systemd problems. – user56041 Mar 28 at 23:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.