You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since Cron.XXXInterval methods should be deprecated as per #1041, a question arises – how to handle intervals then? One could use ScheduledState to create a job and re-schedule after each completion. But this is not an obvious option, and could lead to much more non-obvious consequences like 5 retries or an original job caused 5 scheduled jobs to be created instead of 1 with a simple implementation.
Instead, recurring jobs should be modified to support the following recurring schemes (yes, there will be no support for seconds yet). This is just to handle simple cases, with a simple implementation. Since recurring job is a has, we could save backward compatibility without any problems.
Every X minutes
Every X hours at MM minutes
Every X days at HH:MM
Every X months at DD day at HH:MM
The text was updated successfully, but these errors were encountered:
I'd like to propose something I've done before to handle cron intervals. I needed a solution to "every 2 weeks" when using Ncrontab Advanced and so I extended the functionality to allow for "Xnn" to be added to a cron expression.
Example:
00 00 * * FRI X2
Without "X2" this would just be every Friday at midnight. But with X2 I would getnextoccurance 2 times and use the second value as the next run time which would be 2 weeks.
This can be useful for doing all kinds of new variations. It can also lead to confusing results sometimes if you don't think about your expression carefully but that's true of all cron expressions.
This I think helps fill in a gap that cron has and has been very useful for my scheduled jobs. Now that I'm using Hangfire I'll love to see this included. The good thing is you can use this with any cron expression and just use a multiple X3 to get it to do what you want.
30 * * * * X3 would be every 3 hours at 30 minutes past the hour.
I'm on the 1.7.0 beta and it works great. If this could somehow be added that would be very helpful. If not I might try my own version with the source either by extending Hangfire or more likely Cronos.
[I posted this in another response as well. Sorry if this confuses, I didn't see this issue then]
Updated MinuteInterval & HourInterval methods to make them available (not obselete) again.
Added defensive code against interval value to get rid of the problem described in HangfireIO#1041
Also related:
HangfireIO#1054HangfireIO#1779
Since
Cron.XXXInterval
methods should be deprecated as per #1041, a question arises – how to handle intervals then? One could useScheduledState
to create a job and re-schedule after each completion. But this is not an obvious option, and could lead to much more non-obvious consequences like 5 retries or an original job caused 5 scheduled jobs to be created instead of 1 with a simple implementation.Instead, recurring jobs should be modified to support the following recurring schemes (yes, there will be no support for seconds yet). This is just to handle simple cases, with a simple implementation. Since recurring job is a has, we could save backward compatibility without any problems.
The text was updated successfully, but these errors were encountered: