-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
The function multiple starts immediately after add into cron #106
Comments
Excuse me, it was fixed in master, but not in |
This fixes robfig/cron#106
For me this is a downgrade of functionality. Think about I would like to update all of my jobs. I would've picked something like this:
This way I could've been sure no interval gets missed while I'm setting up the new list. Because some of the items that are getting added to the new cron object are old ones from the previous cron object. I hope it's clear what I'm talking about. Hope to find some other safe way. |
I agree that it is a bug. v3 branch has this fix, and it has other fixes too. I recommend upgrading to it. |
I'm trying to add function into CRON to running every minute:
c.AddFunc("*/1 * * * *", func() { log.Println("Run every minute") })
If I do it immediately after cron object was created, then code works as expected - the function will be executed every minute, starting at the beginning of the next minute.
But if I will add the function in a minute after the current (or later - after 2, 3 and more minutes), it begins to execute immediately after you add into the cron.
In addition, it executed as many times as the minutes passed between the creation of the cron and function was added.
For example, if you try to run the following code:
So, the function will call exactly 2 times immediately after adding into cron, because it took 2 minutes between the start of the cron (12:31:36) and adding the function into it (12:33:36).
If between execute
c.Start()
andc.AddFunc
took 3 minutes, then we would see in the logs three callsRun every minute
.In my opinion, the first time the function should be executed at the beginning of the next minute - 12:34:00 and repeat every minute.
The text was updated successfully, but these errors were encountered: