0

systemd 219 version

Ubuntu 22.04.2 LTS

[Unit]
Description=Run myscript.service every 5 minutes

[Timer]
OnCalendar= *-*-* 10-23:10/5:00
Persistent=true

[Install]
WantedBy=timers.target

I need to run my service every hour past 10 minutes until 23:10. (10:10, 11:10, 12:10 ..23:10). I face difficulty in indicating the hours range.

I have tried 10-23, 10..23 even pasted the same date from another post. Still did not work.

Error

Dec 27 16:48:09 node1 systemd[1]: [/etc/systemd/system/myscript.timer:5] Failed to parse calendar specification, ignoring: *-*-* 10..23:10/5:00
Dec 27 16:48:09 node1 systemd[1]: myscript.timer lacks value setting. Refusing.
Dec 27 16:52:51 node1 systemd[1]: [/etc/systemd/system/myscript.timer:5] Failed to parse calendar specification, ignoring: *-*-*10..23:10/5:00
Dec 27 16:52:51 node1 systemd[1]: myscript.timer lacks value setting. Refusing.
Dec 27 16:55:18 node1 systemd[1]: [/etc/systemd/system/myscript.timer:5] Failed to parse calendar specification, ignoring: *-*-* 9-17:00:00
Dec 27 16:55:18 node1 systemd[1]: myscript.timer lacks value setting. Refusing.
Dec 27 16:56:45 node1 systemd[1]: [/etc/systemd/system/myscript.timer:5] Failed to parse calendar specification, ignoring: *-*-* 9-18:00:00
Dec 27 16:56:45 node1 systemd[1]: myscript.timer lacks value setting. Refusing.
Dec 27 16:57:59 node1 systemd[1]: [/etc/systemd/system/myscript.timer:5] Failed to parse calendar specification, ignoring: *-*-* 10-23:10/5:00
Dec 27 16:57:59 node1 systemd[1]: myscript.timer lacks value setting. Refusing.

1 Answer 1

1

Support for the x..y syntax for time ranges was only added in systemd version 231.

CHANGES WITH 231:

        * Calendar time specifications in .timer units now understand a ".."
          syntax for time ranges. Example: "4..7:10" may now be used for
          defining a timer that is triggered at 4:10am, 5:10am, 6:10am and
          7:10am every day.

With older versions, you'll need to specify multiple OnCalendar= settings, one for each hour – or change the script itself to check current time and immediately exit if outside the interval.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .