On Sat, Jul 10, 2021 at 02:07:53PM +0000, Job Snijders wrote:
> Hi all,
> 
> The below patch adds a new kind of time specifier: an interval (in
> minutes). When used, cron(8) will schedule the next instance of a job
> after the previous job has completed and a full interval has passed. 
> 
> A crontab(5) configured as following:
> 
>     $ crontab -l
>     @3 sleep 100
> 
> Will result in this schedule:
> 
>     Jul 10 13:38:17 vurt cron[96937]: (CRON) STARTUP (V5.0)
>     Jul 10 13:42:01 vurt cron[79385]: (job) CMD (sleep 100)
>     Jul 10 13:47:01 vurt cron[3165]: (job) CMD (sleep 100)
>     Jul 10 13:52:01 vurt cron[40539]: (job) CMD (sleep 100)
>     Jul 10 13:57:01 vurt cron[84504]: (job) CMD (sleep 100)
> 
> A use case could be running rpki-client more frequently than once an
> hour:
> 
>     @15 -n rpki-client && bgpctl reload
> 
> The above is equivalent to:
> 
>     * * * * * -sn sleep 900 && rpki-client && bgpctl reload
> 
> 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. I was able
> to leverage the 'singleton' infrastructure. And removed a comment that
> reads like a TODO nobody is going to do.
> 
> Thoughts?
> 
> Kind regards,
> 
> Job
> 

hi.

just to be clear - the point here is that you don;t know how long a job
takes to run, so you can't specify the interval in the normal way?

the doc changes look fine, but i have some suggestions:

> Index: crontab.5
> ===================================================================
> RCS file: /cvs/src/usr.sbin/cron/crontab.5,v
> retrieving revision 1.41
> diff -u -p -r1.41 crontab.5
> --- crontab.5 18 Apr 2020 17:11:40 -0000      1.41
> +++ crontab.5 10 Jul 2021 13:38:13 -0000
> @@ -265,7 +265,7 @@ For example,
>  would cause a command to be run at 4:30 am on the 1st and 15th of each
>  month, plus every Friday.
>  .Pp
> -Instead of the first five fields, one of eight special strings may appear:
> +Instead of the first five fields, one of nine special strings may appear:

instead of being specific about numbers, we could just say "one of these
special strings". then we don;t have to keep changing the text.

>  .Bl -column "@midnight" "meaning" -offset indent
>  .It Sy string Ta Sy meaning
>  .It @reboot Ta Run once, at startup.
> @@ -276,6 +276,14 @@ Instead of the first five fields, one of
>  .It @daily Ta Run every midnight (0 0 * * *).
>  .It @midnight Ta The same as @daily.
>  .It @hourly Ta Run every hour, on the hour (0 * * * *).
> +.It Pf @ Ar minutes Ta The

the field "minutes" could be confusing, because the other fields
are similar type (hourly, daily, etc) and literal, whereas this is
an argument name. would it be clearer to use sth like "n", a more
common arg name for an arbitrary number, which would also match
your text "followed by a numeric value"?

that's not a request, it's a question ;)

> +.Sq @
> +symbol followed by a numeric value has a special notion of running a job
> +after an interval specified in minutes has passed, and the previous
> +instance has completed.
> +The first run is scheduled at a full interval after
> +.Xr cron 8
> +started.

i hate how every other entry here is a succint one-liner, and this
addition is a block. i wonder if we could be super trim here, and
be more expansive using an example. i already feel from the text
that i don;t really understand when i might use this, so an example
might help.

for example:

        ...
        @n      Run after previous job + "n" minutes have elapsed.
        ...
        EXAMPLES
        ...
        # the gories
        #
        #
        @15 -n rpki-client && bgpctl reload

jmc

>  .El
>  .Sh ENVIRONMENT
>  .Bl -tag -width "LOGNAMEXXX"
> @@ -346,7 +354,9 @@ MAILTO=paul
>  5 4 * * sun     echo "run at 5 after 4 every sunday"
>  
>  # run hourly at a random time within the first 30 minutes of the hour
> -0~30 * * * *   /usr/libexec/spamd-setup
> +0~30 * * * *    /usr/libexec/spamd-setup
> +
> +@10             sleep 180 && echo "starts every 13 minutes, implies -s"
>  .Ed
>  .Sh SEE ALSO
>  .Xr crontab 1 ,
> @@ -372,6 +382,8 @@ Random intervals are supported using the
>  character.
>  .It
>  Months or days of the week can be specified by name.
> +.It
> +Interval mode.
>  .It
>  Environment variables can be set in a crontab.
>  .It

Reply via email to