Set an "on demand" only job in HangFire

Askolein picture Askolein · Jun 2, 2016 · Viewed 7k times · Source

In Hangfire, I have successfully set recurring jobs and am able to trigger manually if I want to, thanks to the Web UI and its "trigger" button.

RecurringJob.AddOrUpdate(..);

enter image description here

But I'm willing to set a job that is never fired automatically. Only on demand from the WebUi. Think of it as a set of maintenance task that are triggered only when needed. Manually.

I was thinking of adding a non-reccuring Job in the await state, but was not able to (and it sounds wrong).

Are "On demand only" jobs possible with Hangfire?

Answer

Edwin picture Edwin · May 3, 2019

I used this (hangfire 1.7 on .net 4.6.2)

RecurringJob.AddOrUpdate(() => ..., "0 0 31 2 0");

It shows up in the dashboard as:

Next execution N/A