Re: [systemd-devel] systemd.timer every X days?

2020-07-29 Thread Richard Hector
On 29/07/20 4:13 am, Ian Pilcher wrote:
> On 7/28/20 11:07 AM, Mantas Mikulėnas wrote:
>> I'd create a single raidcheck.service that runs daily and calls a
>> script that itself determines which device to check, e.g.
>> /dev/md$[dayofyear % 16].
> 
> That is the approach that I'm taking, although it means a fair bit of
> work.  I need to parse a configuration file, do a bunch of date-related
> math, etc., as I don't really want to hard-code the number of RAID
> devices into a C program.

Why not just record which one you've just finished, then next time, read
that and do the next in the sequence?

Richard
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] systemd.timer every X days?

2020-07-28 Thread Ian Pilcher

On 7/28/20 11:07 AM, Mantas Mikulėnas wrote:
I'd create a single raidcheck.service that runs daily and calls a script 
that itself determines which device to check, e.g. /dev/md$[dayofyear % 16].


That is the approach that I'm taking, although it means a fair bit of
work.  I need to parse a configuration file, do a bunch of date-related
math, etc., as I don't really want to hard-code the number of RAID
devices into a C program.

--

 In Soviet Russia, Google searches you!

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] systemd.timer every X days?

2020-07-28 Thread Mantas Mikulėnas
I'd create a single raidcheck.service that runs daily and calls a script
that itself determines which device to check, e.g. /dev/md$[dayofyear % 16].

On Sun, Jul 26, 2020, 22:56 Ian Pilcher  wrote:

> My NAS has 16 MD RAID devices.  I've created a simple service
> (raidcheck@.service) that will trigger a check of the RAID device
> identified by the argument.  E.g., 'systemctl start raidcheck@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?
>
> --
> 
>   In Soviet Russia, Google searches you!
> 
>
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] systemd.timer every X days?

2020-07-28 Thread Lennart Poettering
On So, 26.07.20 14:56, Ian Pilcher (arequip...@gmail.com) wrote:

> My NAS has 16 MD RAID devices.  I've created a simple service
> (raidcheck@.service) that will trigger a check of the RAID device
> identified by the argument.  E.g., 'systemctl start raidcheck@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?

So what you are trying to do here is a mixture of calendar based
scheduling and monotonic scheduling. You could schedule the first
iteration via OnCalendar= and then schedule subsequent iterations via
OnUnitActiveSec=, but it's sloppy, since first of all this will
accumulate the latency of activation, and then as soon as you have a
DST change things will go completely off.

We might be able to extend our calendar language natively to support
something like this, i.e. calendar expressions that use monotonic
adjusted repetition values, but quite frankly I don't even know how
such an expression language could look like.

Maybe a workable way is to just enqueue a transient timer for the next
iteration at the end (or beginning) of your service, i.e. use
systemd-timer with some minimal shell scripting. i.e.

systemd-run --on-calendar=`date --date=@$((\`date -u +%s\` + 
16*24*60*60+12*60*60)) %d-%m-%y 23:00:00` …

(totally untested, but you get the idea: add 16.5 days to the current
unix day, then break that down to the day, and use that to re-enqueue
a transient calendar event)

Lennart

--
Lennart Poettering, Berlin
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] systemd.timer every X days?

2020-07-27 Thread Andrei Borzenkov
26.07.2020 22:56, Ian Pilcher пишет:
> My NAS has 16 MD RAID devices.  I've created a simple service
> (raidcheck@.service) that will trigger a check of the RAID device
> identified by the argument.  E.g., 'systemctl start raidcheck@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.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] systemd.timer every X days?

2020-07-26 Thread Ian Pilcher

My NAS has 16 MD RAID devices.  I've created a simple service
(raidcheck@.service) that will trigger a check of the RAID device
identified by the argument.  E.g., 'systemctl start raidcheck@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?

--

 In Soviet Russia, Google searches you!


___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel