Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unix crontab nextExecution bug #45

Closed
mjsaber opened this issue Oct 14, 2015 · 4 comments
Closed

Unix crontab nextExecution bug #45

mjsaber opened this issue Oct 14, 2015 · 4 comments
Milestone

Comments

@mjsaber
Copy link
Contributor

mjsaber commented Oct 14, 2015

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

@jmrozanec
Copy link
Owner

@mjsaber Thank you for reporting this. We are working on a solution right now. Will keep you posted about updates on this issue.

@jmrozanec jmrozanec changed the title nextExecution bug Unix crontab nextExecution bug Oct 15, 2015
@jmrozanec
Copy link
Owner

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.

jmrozanec added a commit that referenced this issue Oct 15, 2015
…ts are now returned in same timezone as reference date.
@jmrozanec
Copy link
Owner

@mjsaber the issue was fixed! Will release a new version with the fixes before weekend.

@jmrozanec
Copy link
Owner

@mjsaber Version 3.1.1 was released including this fix!

@jmrozanec jmrozanec added this to the 3.1.1 milestone Oct 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants