How to remove all hangfire recurring jobs on startup?

A bit late on this one but hopefully it will help someone else. I got stuck in the same situation. In the end the answer on HangFire recurring task data helped me out.

I use the JobStorage to loop through all recurring jobs and remove each in turn as below:

using (var connection = JobStorage.Current.GetConnection())
{
    foreach (var recurringJob in connection.GetRecurringJobs())
    {
        RecurringJob.RemoveIfExists(recurringJob.Id);
    }
}

I am sure there is a nicer way out there but I couldn’t find it

Leave a Comment

tech