later icon indicating copy to clipboard operation
later copied to clipboard

cron day/weekday issue

Open mykhailosh opened this issue 12 years ago • 2 comments

if we have both day and weekday values, there is an incorrect calculation. See sample: http://jsfiddle.net/SmYqS/

man 5 crontab: Note: The day of a command's execution can be specified by two fields — day of month, and day of week. If both fields are restricted (i.e., aren't *), the command will be run when either field matches the current time.

mykhailosh avatar May 23 '13 11:05 mykhailosh

Thanks for catching this. I remember reading that and then apparently completely forgot about it. I'll create a fix shortly, but in the meantime you can work around this by breaking up the cron schedule and concatenating the results:

var s1 = cronParser().parse('* * 10 * *');
var s2 = cronParser().parse('* * * * 5');

s1.schedules = s1.schedules.concat(s2.schedules);
s1.exceptions = s1.exceptions.concat(s2.exceptions);

var result = later(60, true).getNext(s1);

bunkat avatar May 23 '13 15:05 bunkat

How it should work now? The next code is not work

var scheduler1 = later.parse.cron( '*  *  10  *  *' );
var scheduler2 = later.parse.cron( '*  *  *  *  5' );

scheduler1.schedules  = scheduler1.schedules.concat( scheduler2.schedules );
scheduler1.exceptions = scheduler1.exceptions.concat( scheduler2.exceptions );

var result = later.schedule(scheduler1).next();

mykhailosh avatar Jun 02 '14 14:06 mykhailosh