[systemd-devel] How to start a task after system boot but only on specific days using systemd.timer

Andrei Borzenkov arvidjaar at gmail.com
Wed Jan 10 04:17:23 UTC 2018


09.01.2018 22:28, Joerg Diederich пишет:
> Hello,
> 
> I have a little (perhaps strange) requirement:
> I want to execute a script about five minutes after system boot, but only on specific weekdays (e. g. Sundays) using systemd.timer. I tried a combination of OnBootSec and OnCalendar like
> 
> OnBootSec=5m
> OnCalendar=Sun
> 
> but this doesn't work.

Well, it works but not they way you want it :) As documented, multiple
directives are additive - timer will trigger when any of them elapses.
May be it could be expressed more obviously.

> My script executes always after boot. I'm running systemd-228-38.1.x86_64 on SuSE LEAP 42.3. Of course, I can modify my script to ask for the current weekday, but I thought, it would be more elegant to configure it all together in the timer unit file.

This would likely require new directive or at least new syntax. Timers
define point in time, not period of time.


More information about the systemd-devel mailing list