timer with multiple oncalendar moments
Is it possible to have it run at multiple moments by declaring it in the same timer?
Yes.
See this excerpt from man systemd.timer
(my emphasis):
OnCalendar= Defines realtime (i.e. wallclock) timers with calendar event expressions. See systemd.time(7) for more information on the syntax of calendar event expressions. Otherwise, the semantics are similar to OnActiveSec= and related settings. Note that timers do not necessarily expire at the precise time configured with this setting, as it is subject to the AccuracySec= setting below. May be specified more than once.
Here is a working example that I use:
[Timer]
OnCalendar=Mon-Sun *-*-* 23:00:00
OnCalendar=Mon-Sun *-*-* 06:00:00
Although this post is a little old, I would like to point out that there are several ways to declare it in the same timer:
- The man of systemd.time specifies that:
Each component can be specified as a list of values separated by commas.
In your case, as only one component changes, I would recommend using this solution. You almost had it, the comma needs to be placed between occurrences of the same component:
OnCalendar=10,21:00
- The man of systemd.timer explains that
OnCalendar=
:
May be specified more than once, in which case the timer unit will trigger whenever any of the specified expressions elapse.
If several components change, then I would recommend using this second solution:
OnCalendar=Mon..Wen 10:00
OnCalendar=Thu..Fri 21:00