On Sat, Jul 10, 2021 at 09:05:15AM -0600, Theo de Raadt wrote: > Job Snijders <j...@openbsd.org> wrote: > > A use case could be running rpki-client more frequently than once an > > hour:
Perhaps I choose a poor example, because of $work *I* run rpki-client very often, but do not recommend others to follow that schedule. :) > After cron has this support, I suspect you will propose that root's > crontab be changed to use the feature, thus further increasing the > compute done directly on a router. It is not my goal to change the root's example crontab. I think the current 1 hour suggestion is appropriate for anno 2021. I agree the CPU cost is considerable, we should work to reduce it - not to increase it. > That then begs the question why cron needs this extension for this > purpose. I am not propsing it for 'this' purpose, the feature is for folks that have jobs of unknown run time who wish to put some distance between two jobs. I saw the feature described in the freebsd manual and just thought to myself 'This looks doable, perhaps others like it too!' :) > > @15 -n rpki-client && bgpctl reload > > > > The above is equivalent to: > > > > * * * * * -sn sleep 900 && rpki-client && bgpctl reload > > Somewhat the same effect, but I think there are big differences in > behaviour. The second version creates a process hierarchy which sleeps > for a long time. I suspect crontab -e causes drastic difference in > behaviour when the job is already running. Good point. I hadn't thought of that. > So I agree with getting away from the sleep pattern. I have never > used it myself, and we should discourage others from using it by > providing something better. > > > 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/7a5c30c5b67555c9f76a053812ba80ae258b8874#diff-f8f4ba67b7df93eb4b436203d0c70670560029bd8c5b9a642691a914aa33d400 to accomplish this. 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. 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. Suggestions welcome! Kind regards, Job