Project

General

Profile

Feature #11858

crontab could support /step

Added by Andy Fiddaman 3 months ago. Updated 3 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
cmd - userland programs
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Hard
Tags:

Description

The cron shipped with many UNIX and UNIX-like systems supports an extension that allows a step to be applied to * or range elements in the crontab file, for example:

*/2 * * * * echo "run every two minutes" 
0 0-7,8-18/4,19-23 * * * echo "run every 4 hours during the working day, every hour outside" 

It would be useful if the illumos cron supported this additional /<step> syntax.

History

#2

Updated by Andy Fiddaman 3 months ago

To test the new field parser, I used the following test data to confirm that the new parser is producing expected output for a range of inputs.

In the output below, the first column is the range of the field as provided to the parser, the second column is the input, and the last column shows the generated sequence or error.

 5-10                         6 OK 6
 5-10                         4 OK OutOfBounds
 5-10                        11 OK OutOfBounds
 5-10                        -1 OK UnexpectedChar
 0-10                         * OK *
 0-10                       *,1 OK UnexpectedChar
 0-19                       */2 OK 0,2,4,6,8,10,12,14,16,18
 0-10                     */2,5 OK 0,2,4,6,8,10,5
 0-10                       1-5 OK 1,2,3,4,5
 5-10                       6-6 OK 6
 0-10                     1,3,5 OK 1,3,5
 0-10                     1,x,5 OK UnexpectedChar
 0-10                      1,,5 OK UnexpectedChar
 0-10                       x-5 OK UnexpectedChar
 0-10                       1-x OK UnexpectedChar
 0-10                     1-5/x OK UnexpectedChar
 0-19                    1-10/2 OK 1,3,5,7,9
 0-59      0,1-6/2,7-20/5,20-23 OK 0,1,3,5,7,12,17,20,21,22,23
 0-23         20-0,1-6/2,7-20/5 OK 20,21,22,23,0,1,3,5,7,12,17
 0-59                     0-5/7 OK 0
 0-59                     0-5/0 OK OutOfBounds
 0-59                 0-59,0-59 OK Overflow
 0-59                     0-100 OK OutOfBounds
 0-59                     100-0 OK OutOfBounds
 0-59                     */100 OK OutOfBounds
 0-59                  5-50/100 OK OutOfBounds
 0-10                       8-2 OK 8,9,10,0,1,2
 0-19                      15-8 OK 15,16,17,18,19,0,1,2,3,4,5,6,7,8
 0-59                   49-10/4 OK 49,53,57,1,5,9
 0-59                   50-10/4 OK 50,54,58,2,6,10
 0-59                   51-10/4 OK 51,55,59,3,7
 0-59                   52-10/4 OK 52,56,0,4,8
 1-58                   50-10/4 OK 50,54,58,4,8
 2-57                   50-10/4 OK 50,54,2,6,10
 3-56                   50-10/4 OK 50,54,4,8
 4-55                   50-10/4 OK 50,54,6,10
40-55                   50-45/4 OK 50,54,42
#3

Updated by Andy Fiddaman 3 months ago

Performed some additional testing:

% ./parsetest 0 59 '20-23,0,7-20/5,1-6/2,7-20/5,20-23 '
    20,21,22,23,0,7,12,17,1,3,5,7,12,17,20,21,22,23

% ./parsetest 0 59 '`cat /dev/random`'
    UnexpectedChar

% cat /usr/dict/words| while read w; do
    ./parsetest 0 59 "$w " 
done | sort | uniq -c

25144 UnexpectedChar
#4

Updated by Electric Monk 3 months ago

  • Status changed from In Progress to Closed
  • % Done changed from 0 to 100

git commit 6b734416901818aa8c4bbb09c12b691ea771dc94

commit  6b734416901818aa8c4bbb09c12b691ea771dc94
Author: Andy Fiddaman <omnios@citrus-it.co.uk>
Date:   2019-10-29T22:55:56.000Z

    11858 crontab could support /step
    Reviewed by: Matthias Scheler <matthias.scheler@wdc.com>
    Reviewed by: Dominik Hassler <hadfl@omniosce.org>
    Approved by: Dan McDonald <danmcd@joyent.com>

Also available in: Atom PDF