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

How to schedule cron tab if time is past/expired. #44

Closed
bhaskarb360 opened this issue Feb 5, 2022 · 2 comments
Closed

How to schedule cron tab if time is past/expired. #44

bhaskarb360 opened this issue Feb 5, 2022 · 2 comments

Comments

@bhaskarb360
Copy link

Say we have current time as 5th Feb 2022 and Time is 15:25:07 while the value of cron is 15:10:10.
How we can handle and execute still that job.
Example as of cron package:
image

@Hexagon
Copy link
Owner

Hexagon commented Feb 5, 2022

Normally,missed jobs is out of scope for a pure cron-style scheduler, but I see that you use CronJob with a specific timestamp - I am considering to support this in croner.

In this specific case I would recommend you to use a simpler approach, that does not rely on the cron library to throw errors.

Something like:

if(response[idx].endDate < new Date()) {
   // Immediately run the stuff, without using a cron library
} else {
   // Create a new cron job that execute in the future
   let job = new Cron(pattern, () => { /* stuff to run */ });
}

But as said, i will consider implementing one-off-scheduling using a single point i time. Follow progress of #4

@Hexagon Hexagon closed this as completed Feb 5, 2022
@anogray
Copy link

anogray commented Feb 5, 2022

It seems it is better to have your own setTimeout logic rather than any other open source .😅

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

3 participants