[systemd-devel] systemd.timer every X days?
Andrei Borzenkov
arvidjaar at gmail.com
Mon Jul 27 19:38:17 UTC 2020
26.07.2020 22:56, Ian Pilcher пишет:
> My NAS has 16 MD RAID devices. I've created a simple service
> (raidcheck at .service) that will trigger a check of the RAID device
> identified by the argument. E.g., 'systemctl start raidcheck at md1' will
> trigger the check of md1 (after checking that no other array is being
> checked/synced, no arrays are degraded, etc.).
>
> It takes 6-8 hours to check one of these arrays, so I want to run one
> check every night at 23:00. So (picking tonight as an arbitrary
> starting point) md1 would run tonight, md2 would run tomorrow night, md3
> would run the following night ... all the way through md16. Then the
> cycle would start over with md1.
>
> I had thought that I would be able to create 16 separate timers (one for
> each device), each scheduled to trigger every 16 days at 23:00, starting
> on a particular day.
>
> Looking through the systemd.timer(5) and systemd.time(7) man pages,
> however, I haven't been able to figure out how to do this. Is it not
> possible, or am I missing something?
>
Not using native timer syntax. Repetition is really shorthand for list
of values in the same period (i.e. 2020-07-03/16 is just short form of
2020-07-03,19); it does not mean "repeat every 16 days from now on".
You could have boot time service that creates 16 timers with something like
systemd-run --on-calendar=first-date-and-time-for-this-timer
--on-unit-active=16days --unit=your.service
This could also be generator, but it also runs on every daemon-reload
which happens quite often.
More information about the systemd-devel
mailing list