3

I would like to run a systemd service hourly from 9am in the morning to 1am at night (one hour past midnight local time).

As a starting point I can use a time specification similar to the following to run a timer from 9am to 11pm: "*-*-* 09..23:00:00"

I can test it with:

systemd-analyze calendar "*-*-* 09..23:00:00"

This appears to work correctly based on the output.

However, when I try something like the following it does not work:

systemd-analyze calendar "*-*-* 09..01:00:00"
Failed to parse calendar specification '*-*-* 08..01:00:00': Invalid argument

I have tried a lot of variations of the following without success yet:

systemd-analyze calendar "*-*-* 00..01:00:00,09..23:00:00"

I think I'm close, but I can't get the notation right. Have referred to https://man.archlinux.org/man/systemd.time.7

1 Answer 1

1

The proper solution looks like this:

OnCalendar=*-*-* 00..01,09..23:00:00

You cannot mix hour and minutes in the notation, which is why this form does not work:

"*-*-* 00..01:00:00,09..23:00:00"

The hourly range needs to be defined before specifying minutes. In this case the hourly range is:

00..01,09..23

You must log in to answer this question.

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