Himanshu Chopra
Himanshu Chopra

Reputation: 53

The Next execution and last execution is N/A in Recurring Jobs - hangfire

I have this code for Recurring Job and this is calling a BackgroundJob.Enqueue

RecurringJob.AddOrUpdate("indexes-scheduler", () => AppBuilderExtensions.checkIndexDate(), Cron.Minutely);

and if I check dashboard after running the project the last execution and next execution shows N/A.

I tried to schedule a simple job

RecurringJob.AddOrUpdate("tests-job", () => Console.WriteLine("This job will execute once in every minute"), Cron.Minutely);

But still the sameenter image description here

Upvotes: 2

Views: 1731

Answers (1)

Himanshu Chopra
Himanshu Chopra

Reputation: 53

Okay I got it working by using this script and also I tried to delete all servers from Hangfire.Server table

 TRUNCATE TABLE [HangFire].[AggregatedCounter]
 TRUNCATE TABLE [HangFire].[Counter]
 TRUNCATE TABLE [HangFire].[JobParameter]
 TRUNCATE TABLE [HangFire].[JobQueue]
 TRUNCATE TABLE [HangFire].[List]
 TRUNCATE TABLE [HangFire].[State]
 TRUNCATE TABLE [HangFire].[Server]
 DELETE FROM [HangFire].[Job]
 DBCC CHECKIDENT ('[HangFire].[Job]', reseed, 0)
 UPDATE [HangFire].[Hash] SET Value = 1 WHERE Field = 'LastJobId'

and eventually recreated those servers using this

app.UseHangfireServer();

This trick worked for me.

Upvotes: 1

Related Questions