On 23-05-05 10:41AM, Todd C. Miller wrote:
> On Fri, 05 May 2023 16:13:01 +1000, Mark Jamsek wrote:
> 
> > I found kn's attempted syntax intuitive though; it feels like a natural
> > extension of the existing random and step syntax. I also assumed ~/15
> > would run every 15 minutes starting with a random minute, and since
> > discovering it didn't work like that, I've been carrying a simple patch
> > that allows kn's syntax:
> >
> >   ~/15              random 15 minute intervals in [0, 59]
> >   1~9/10            random 10 minute intervals in [1,59]
> 
> It does seem like people prefer the ~/step syntax over my own, which
> is fine.
> 
> However, I'm unsure about the x~y/step syntax.  Personally, I think
> it would be more natural to treat x~y/step like x-y/step and just
> use a random offset in the interval [0,step-1].  Do you have a
> use-case for the way your diff handles this or did it just follow
> naturally from the random value being in num1?
> 
> Also, using the % operator with the random value results in modulo
> bias, which we would like to avoid.  If we use a random offset based
> on the step interval instead there is no need for the modulus.

Both tbh. I primarily wanted to get intervals that would not fall on
common times where I already had jobs running; namely, 0th minutes
(e.g., 0, 30). And I described the second example wrong, so this was
most likely lost in my first response:

> >   1~9/10            random 10 minute intervals in [1,59]

The "intervals in [1,59]" is not correct in this example. Rather, this
will result in an initial random value 1 <= n <= 9, so each interval in
this step /10 case will also fall in [N1,N9] (e.g., 7, 17, 27, ...) and
avoid said common times. And the modulo is used to get the first point
in [low,high] from which to start the step loop that fit this
constraint. In other words, I wanted some control over where the random
intervals landed such that being able to avoid ranges was as much
a requirement, in my use case, as random steps.

But I also didn't want to change the code too much so it just followed
naturally. This could be done other ways, too, and I'm not presuming
such a requirement is as important to anyone else.

-- 
Mark Jamsek <fnc.bsdbox.org|got.bsdbox.org>
GPG: F2FF 13DE 6A06 C471 CA80  E6E2 2930 DC66 86EE CF68

Reply via email to