I have the problem that scheduled Hangfire jobs that should be carried out every day are switched off as soon as I close the local host.
This is my Code in the HomeController:
public void TriggerFunction() {
RecurringJob.AddOrUpdate(() => Update(), Cron.Daily());
}
if I execute localhost/Home/TriggerFunction and then localhost/Hangfire I can see the jobs in the Hangfire overview. As soon as I run the project again and go only to localhost/Hangfire it says: no jobs
i am facing same issue also
try
{
if (!_database.ExecuteScalar($“select count(*) from [HangFire].[Hash] where [Key] like ‘%test-job%’”))
{
RecurringJob.AddOrUpdate(“test-job”, () => _clubService.TaskAsync(), Cron.MinuteInterval(2));
}
}
catch (Exception ex)
{
await _database.ExecuteScalarAsync(“insert into logs(CreatedDate,Details,Status,StackTrace,CustomerId) values(@CreatedDate,@Details,@Status,@StackTrace,@CustomerId)”, new
{
CreatedDate = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now, TimeZoneInfo.Local),
Details = $“Error while creating recurring job message : ‘{ex.Message}’”,
CustomerId = User.GetUserId(),
Status = “”,
StackTrace = “”
}).ConfigureAwait(false);
}