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

Upcoming and Resuming Schedules #125

Open
kennetpostigo opened this issue Jul 25, 2024 · 1 comment
Open

Upcoming and Resuming Schedules #125

kennetpostigo opened this issue Jul 25, 2024 · 1 comment

Comments

@kennetpostigo
Copy link

I have 2 questions:

  1. I started my server at 4:30PM and I have a cron job that should run every weekday at 6:00PM 0 0 18 * * Mon,Tue,Wed,Thu,Fri. And I take 1 off the upcoming schedule schedule.upcoming(Utc).take(1).next().unwrap(). Then I log it and I get Job scheduled at: 2024-07-26T18:00:00Z(tomorrow). However it's 4:30PM and 6:00PM is an hour and thirty minutes away, why isn't it's next start time in an hour and thirty minutes 2024-07-25T18:00:00Z(today)?
  2. Resuming a job, i'm not sure how to do it with cron. For example lets say I redeploy my application during the day at a time that happens to fall during the running of a job like */5 * 10-12 * * Mon,Tue,Wed,Thu,Fri that runs every 5 seconds from 10AM to 12PM. Lets say I redploy my applicatoin at 11AM the next upcoming schedule for the cron job */5 * 10-12 * * Mon,Tue,Wed,Thu,Fri is tomorrow, but I would like it to resume doing what it was doing, is there a way to do this with cron?
@zslayton
Copy link
Owner

  1. Could you turn your first question into a unit test that fails? That would help both in debugging and in making sure that the problem is fixed. You don't mention what timezone your machine is in, which would influence the Utc view of the next fire time.
  2. I believe I'm missing something. If the job runs every five seconds between 10 and noon and your application checks the schedule at 11am, it should be told that the next fire time is five seconds away. If instead it tells you that the next fire time is a day away, that sounds like a bug. Could you please make a failing unit test for this one too?

For both of these, use the Schedule::after method to specify the time after which you'd like the next fire time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants