Hangfire icon indicating copy to clipboard operation
Hangfire copied to clipboard

Only disable Recurring jobs

Open Caldas opened this issue 11 years ago • 23 comments

I've expiried an network problem with some SQL database and the jobs related to consume data from there started to get error, ok.

I know that I will take at least 8 hours (8 executions, it's hourly) so I had to exclude the recurring jobs but my intention was only disable it, get some sleep fix the dam network problem and re-enable my recurring SQL data consuption jobs.

So a disable button on hangfire/recurring page would be very useful.

Caldas avatar Aug 06 '14 05:08 Caldas

Currently, recurring job scheduler will schedule a new job regardless of the processing status of previous job. Consider you have an option that the scheduler enqueues new job only on successful completion of the previous job. Will this option solve your problem?

odinserj avatar Aug 09 '14 07:08 odinserj

Is there an option to disable recurring jobs upon successful completion ? Meaning currently i have a job which runs every 20 mins from 6 PM to 7 PM , so basically 6:00/ 6:20 /6:40. So if is is successful the first time, can we stop the recurring job for just the next 2 intervails, so it will continue the next day.

In short change the next execution time to the next day.

jacobneroth avatar Aug 20 '14 00:08 jacobneroth

@jacobneroth, consider you can specify the retry intervals on your recurring job that is being executed daily:

[AutomaticRetry(Attempts = 3, Intervals = "1200")] // Intervals in seconds separated by commas
public void SomeMethod() { }

So in case of exception (unsuccessful execution) it will be retried automatically. Will this help you?

Disclaimer: feature described in this message is not related to recurring jobs and this issue.

odinserj avatar Aug 20 '14 19:08 odinserj

+1 for Enable & Disable buttons in Dashboard for recurring jobs and corresponding methods in API – this is pretty simple. This feature should be implemented after #158, #160, #167 to fix bugs first.

odinserj avatar Aug 20 '14 19:08 odinserj

Great.

In my case, sometimes, the server that I get data from get out of network and when this happens usually infra team take hours to re-establish the server. It would be great have a way to disable jobs and enable it back when infra is ready again

-----Mensagem Original----- De: "Sergey Odinokov" [email protected] Enviada em: ‎20/‎08/‎2014 16:21 Para: "HangfireIO/Hangfire" [email protected] Assunto: Re: [Hangfire] Only disable Recurring jobs (#173)

+1 for Enable & Disable buttons in Dashboard and corresponding methods in API. This feature should be implemented after #158, #160, #167 to fix bugs first. Scheduled to the next release. — Reply to this email directly or view it on GitHub.

Caldas avatar Aug 21 '14 16:08 Caldas

I was surprised to learn that this functionality is not included. It seems rather simple to include a flag on the recurring job?

Moulde avatar Nov 16 '15 12:11 Moulde

This is something I was hoping was in there (as I needed it tonight). Will take a look to see if I can offer a PR to implement this as it's been kicking around since 2014.

bsimser avatar Jan 30 '16 10:01 bsimser

Has there been any progress on this? I would also like this feature and will customise the code if required but my preference would be if it was included as base functionality.

jyoung80 avatar Mar 18 '16 04:03 jyoung80

This would be VERY useful in an corporate, production environment. Otherwise we have to create custom extensions, and modify every time we add a recurring job.

WaltDaniels avatar May 12 '16 20:05 WaltDaniels

This is absolutely a must. Any progress ?

cemremengu avatar Mar 20 '17 18:03 cemremengu

Need this :/

MichalGrzegorzak avatar Jun 06 '17 15:06 MichalGrzegorzak

+1

dlazzarino avatar Aug 02 '17 09:08 dlazzarino

I tried to convince my team to start using hang fire and the lack of this feature Made almost every-one complain.

adgoan avatar Sep 25 '17 14:09 adgoan

@odinserj could you please share your thoughts about this issue and feature to enable\disable specific recurrent tasks? And if someone would actually make a pull request, would you consider to merge it? Or you have some preference to don't have such feature and won't accept such pull request? Thanks

sergey-litvinov avatar Sep 28 '17 07:09 sergey-litvinov

Also interested in this feature. Seems right now there is only an option to delete the RecurringJob (with no way of removing the delete option, causing it to be gone until application restart). I would much rather the option to disable/enable and also the option to not allow delete from dashboard. I have defined the recurring job in the code, I do not want someone to delete it from the dashboard (requiring an application restart or code to constantly add them back) where as enabling/disabling temporarily makes perfect sense.

shaneray avatar Nov 17 '17 22:11 shaneray

@odinserj Any progress?

suadev avatar Jan 02 '18 06:01 suadev

Here is a workaround

https://discuss.hangfire.io/t/pause-disable-recurring-job/125

MirkoFl avatar Jan 10 '18 14:01 MirkoFl

I have tried that workaround but I don't like it. The jobs don't really get paused, they just immediately get cancelled when they are triggered, resulting in "Succeeded" state.

RudeySH avatar Jul 27 '18 20:07 RudeySH

This workaround is not working now, filter is ignored on application pool restart.

RomanVashchegin avatar May 24 '19 11:05 RomanVashchegin

@odinserj so 6 yrs since this was opened. Any progress or ETA?

udlose avatar Sep 29 '20 19:09 udlose

You can programmatically "disable" them by setting the CRON expression to something silly like "0 0 31 2 *".

RecurringJob.AddOrUpdate(() => Foo(), "0 0 31 2 *"); // February 31st (a.k.a. never)

This will appear as DISABLED in the dashboard.

image

You can programmatically enable the jobs by setting the CRON expression back to something useful.

This is an ugly workaround but it sort of works.

RudeySH avatar Sep 29 '20 23:09 RudeySH

You can programmatically "disable" them by setting the CRON expression to something silly like "0 0 31 2 *".

RecurringJob.AddOrUpdate(() => Foo(), "0 0 31 2 *"); // February 31st (a.k.a. never)

This will appear as DISABLED in the dashboard.

image

You can programmatically enable the jobs by setting the CRON expression back to something useful.

This is an ugly workaround but it sort of works.

There is a Cron.Never option available for this that does the same thing: #1432

I plan to make the CRON schedules for my recurring jobs configurable as app settings, giving me the ability to disable a recurring job using the Cron.Never option. It would be nice if there was a convenient button for this on the Hangfire dashboard, but I can make this work.

Zureka avatar Sep 15 '21 20:09 Zureka

This is a must-have feature! Any updates on if this is going to be implemented?

backstromjoel avatar Feb 24 '25 09:02 backstromjoel