Re: [PATCH 6/6] maintenance: use random minute in systemd scheduler
- From
Derrick Stolee <derrickstolee@github.com>
- Date
- Aug 8, 2023, 17:24 UTC
- Message-ID
- <5bb4313a-01f3-4dea-b724-fb41a8def334@github.com>
- In-Reply-To
- <8aa7be24-f4a8-4515-8425-dd4bc69e07b1@github.com>
On 8/8/2023 9:56 AM, Derrick Stolee wrote:
> On 8/8/2023 5:53 AM, Phillip Wood wrote:> Hi Stolee
Show 15 quoted lines
>> So only one of these jobs will succeed. The cron entries are careful to >> only run one job at a time, I think it would be worth doing the same >> thing here. I think the using the following format strings would fix this. >> >> Hourly: "Tue..Sun *-*-* 1..23:00:%02d" >> Daily: "Tue..Sun *-*-* 00:00:%02d" >> Weekly: "Mon *-*-* 00:00:%02d" > > I would modify this with dropping the "Tue..Sun" from the hourly schedule, > as we still want 23 runs on Mondays. > >> It looks like the launchctl schedule has the same issue. > > I will take a look at this and consider some additional patches to correct > these issues across both schedulers. Thank you for the attention to detail!
Taking a look, it seems that launchctl does not have this same problem.
The schedule is set via an <array> of <dict>s as follows:
case SCHEDULE_HOURLY: repeat = "<dict>\n" "<key>Hour</key><integer>%d</integer>\n" "<key>Minute</key><integer>%d</integer>\n" "</dict>\n"; for (i = 1; i <= 23; i++) strbuf_addf(&plist, repeat, i, minute); break;
case SCHEDULE_DAILY: repeat = "<dict>\n" "<key>Day</key><integer>%d</integer>\n" "<key>Hour</key><integer>0</integer>\n" "<key>Minute</key><integer>%d</integer>\n" "</dict>\n"; for (i = 1; i <= 6; i++) strbuf_addf(&plist, repeat, i, minute); break;
This means that we create an hourly schedule for each hour 1..23 (no 0th hour means no collision with daily or weekly schedule) and a daily schedule for each day 1..6 (no 0th day means no collision with the weekly schedule).
Does this match your understanding?
The overlap _definitely_ exists in systemd, which I will fix.
Thanks, -Stolee