To list the recurring jobs in Hangfire, you can use the GetRecurringJobs()
method from the RecurringJobManager
class.
Here's an example of how you can use the GetRecurringJobs()
method to list the recurring jobs in Hangfire:
using Hangfire; using Hangfire.Common; using Hangfire.States; var recurringJobs = RecurringJob.GetRecurringJobs(); foreach (var recurringJob in recurringJobs) { Console.WriteLine("Job ID: " + recurringJob.Id); Console.WriteLine("Job Name: " + recurringJob.Name); Console.WriteLine("Cron Expression: " + recurringJob.Cron); Console.WriteLine("Last Execution: " + recurringJob.LastExecution); Console.WriteLine("Next Execution: " + recurringJob.NextExecution); Console.WriteLine("-------------------"); }
This code will retrieve a list of recurring jobs using the GetRecurringJobs()
method and then iterate through the list, printing the ID, name, cron expression, last execution time, and next execution time for each job.
Note that the GetRecurringJobs()
method returns a list of RecurringJobDto
objects, which contain information about the recurring job, such as the ID, name, cron expression, and execution times.
For more information about recurring jobs in Hangfire, you can refer to the Hangfire documentation (https://www.hangfire.io/docs/recurring-jobs/index.html).