C
C#2mo ago
IsNotNull

Hangfire Execution Time

I have a recurring job I've scheduled in Hangfire. If the app is not running and misses executions, then it might run multiple times when the app starts again. How do I get access to the time that the job was supposed to have run for, but was missed? It doesn't look like Hangfire provides any context for the job execution in the called method. Is this the kind of thing that has to be applied with a filter?
3 Replies
Keswiik
Keswiik2mo ago
I don't think it's exposed by default, but you can access recurring job data directly through JobStorage.Current.GetConnection().GetRecurringJobs(). The List<RecurringJobDto> it returns has last/next execution times, ids to enqueued jobs, and other info doesn't exactly fit what you're asking for but you should be able to figure out what job executions were missed using it
IsNotNull
IsNotNull2mo ago
Its really odd that a library that schedules execution times can't supply the scheduled time at execution. Thanks for the info @ded
Keswiik
Keswiik2mo ago
yeah i always found it odd, most of my projects using hangfire end up with some convenience methods to load recurring job info lol
Want results from more Discord servers?
Add your server