Unix crontab nextExecution bug
I'm trying a simple unix crontab "* * * * 1", which should run every minute of every hour Mondays in every month, but nextExecution doesn't seem give the correct result. Following is the code:
crontab = "* * * * 1";
CronDefinition cronDefinition = CronDefinitionBuilder.instanceDefinitionFor(CronType.UNIX);
CronParser parser = new CronParser(cronDefinition);
Cron cron = parser.parse(crontab);
DateTime date = DateTime.now();
System.out.println("now:" + date);
ExecutionTime executionTime = ExecutionTime.forCron(cron);
DateTime nextExecution = executionTime.nextExecution(date);
DateTime lastExecution = executionTime.lastExecution(date);
System.out.println("next execution:" + nextExecution);
System.out.println("last execution:" + lastExecution);
Output: now:2015-10-13T17:26:54.468-07:00 next execution:2015-11-02T00:00:00.000-08:00 last execution:2015-10-05T23:59:00.000-07:00
The last execution time seems correct, but next execution time should be 2015-10-19T00:00:00.000-07:00. It skips two weeks and also change the time zone. Can you guys take a look at it?
Thanks, Jun
@mjsaber Thank you for reporting this. We are working on a solution right now. Will keep you posted about updates on this issue.
This issue exposes bad next/previous execution calculation as well as the fact that predicted time is always computed in local timezone, not in same timezone as reference date.
@mjsaber the issue was fixed! Will release a new version with the fixes before weekend.
@mjsaber Version 3.1.1 was released including this fix!