Maybe something like this:
--- /home/defer/temp/scron/crond.c      2014-07-05 12:16:11.917457442 +0300
+++ crond.c     2014-07-05 12:47:43.147434577 +0300
@@ -23,6 +23,7 @@
 struct range {
        int low;
        int high;
+       int div;
 };

 struct ctabentry {
@@ -150,12 +151,15 @@ matchentry(struct ctabentry *cte, struct
        size_t i;

        for (i = 0; i < LEN(matchtbl); i++) {
                /* this is the match-any case, '*' */
                if (matchtbl[i].r->low == -1 && matchtbl[i].r->high == -1)
                        continue;
                if (matchtbl[i].r->high == -1) {
                        if (matchtbl[i].r->low == matchtbl[i].tm)
                                continue;
+                       else if (matchtbl[i].tm % matchtbl[i].r->div == 0)
+                               continue;
                } else {
                        if (matchtbl[i].r->low <= matchtbl[i].tm &&
                            matchtbl[i].r->high >= matchtbl[i].tm)
@@ -171,7 +175,7 @@ matchentry(struct ctabentry *cte, struct
 static int
 parsefield(const char *field, int low, int high, struct range *r)
 {
-       int min, max;
+       int min, max, div;
        char *e1, *e2;

        if (strcmp(field, "*") == 0) {
@@ -180,6 +184,7 @@ parsefield(const char *field, int low, i
                return 0;
        }

+       div = -1;
        max = -1;
        min = strtol(field, &e1, 10);

@@ -190,6 +195,15 @@ parsefield(const char *field, int low, i
                if (e2[0] != '\0')
                        return -1;
                break;
+       case '*':
+               e1++;
+               if (e1[0] == '/') {
+                       e1++;
+                       div = strtol(e1, &e2, 10);
+                       if (e2[0] != '\0')
+                               return -1;
+                       break;
+               }
        case '\0':
                break;
        default:
@@ -204,6 +218,7 @@ parsefield(const char *field, int low, i

        r->low = min;
        r->high = max;
+       r->div = div;
        return 0;
 }

On Sat, Jul 5, 2014 at 12:35 PM, Dimitris Papastamos <[email protected]> wrote:
> On Sat, Jul 05, 2014 at 11:41:00AM +0400, Jack L. Frost wrote:
>> No */n for “every n <unit>”?
>> Pretty much useless without that if you ever need a command to be run every 
>> five minutes, for example.
>
> I've forked scron[0] and I plan to implement */n at some point.  If
> you get to it first, please send a patch here.
>
> [0] http://git.2f30.org/scron
>

Attachment: scron-divisible.patch
Description: Binary data

Reply via email to