On Sat, 10 Jul 2021 15:54:51 -0000, Job Snijders wrote:

> > > I borrowed the idea from FreeBSD's cron [1]. A difference between
> > > the below changeset and the freebsd implementation is that they
> > > specify the interval in seconds, while the below specifies in
> > > minutes.
> > 
> > Why be incompatible?  Better have a strong justification.
>
> OpenBSD cron would need to be extended to support 'up to 1 second
> precise' scheduling, perhaps some code can be borrowed from 
> https://github.com/freebsd/freebsd-src/commit/7a5c30c5b67555c9f76a053812ba80a
> e258b8874#diff-f8f4ba67b7df93eb4b436203d0c70670560029bd8c5b9a642691a914aa33d4
> 00
> to accomplish this.

We use ppoll(2) when waiting for the next event so it should be
simple to add support for sub-minute resolution.  Our code differs
greatly from FreeBSD's in this way.

> Alternatively, I can remove the below '* SECONDS_PER_MINUTE' multiplier,
> so that from a syntax perspective we are equivalent to FreeBSD, but our
> cron will have 'one minute precision' regarding when the job is
> executed.

I think maintaining compatibility with FreeBSD is the way to go
since that is where this feature originates.  We can add sub-minute
precision separately.

> entry.c:
> +             } else if (*cmd != '\0' &&
> +                 (interval = strtol(cmd, &endptr, 10)) > 0 &&
> +                 *endptr == '\0') {
> +                     e->interval = interval * SECONDS_PER_MINUTE;
> +                     e->flags |= INTERVAL | SINGLE_JOB;
>
> For me 'one minute' precision is good enough, but if others think it is
> worth putting in the effort to get to '1 second' precision scheduling
> I'm happy to try to hack it.

Currently, cron_sleep() takes a target time in minutes but it doesn't
have to be that way.  We could set the target time based the first
job in the queue or now + 1 minute, whichever is smaller.

 - todd

Reply via email to