Cronitor.Hangfire
1.8.78
dotnet add package Cronitor.Hangfire --version 1.8.78
NuGet\Install-Package Cronitor.Hangfire -Version 1.8.78
<PackageReference Include="Cronitor.Hangfire" Version="1.8.78" />
<PackageVersion Include="Cronitor.Hangfire" Version="1.8.78" />
<PackageReference Include="Cronitor.Hangfire" />
paket add Cronitor.Hangfire --version 1.8.78
#r "nuget: Cronitor.Hangfire, 1.8.78"
#:package Cronitor.Hangfire@1.8.78
#addin nuget:?package=Cronitor.Hangfire&version=1.8.78
#tool nuget:?package=Cronitor.Hangfire&version=1.8.78
Cronitor.Hangfire
Reports every Hangfire recurring job to Cronitor: run when the job starts, complete when it succeeds, and fail, with the exception's message, when it throws.
Install
dotnet add package Cronitor.Hangfire
The package's major version matches Hangfire's: version 1 is for Hangfire 1 (1.8.25 or later).
Setup
Dependency injection
Register Cronitor with .ConfigureCronitor(), then call UseCronitor(provider) when adding Hangfire:
using Cronitor.Extensions;
using Cronitor.Hangfire;
using Hangfire;
await Host.CreateDefaultBuilder()
.ConfigureCronitor((context) => context.Configuration.GetValue<string>("Cronitor:ApiKey"))
.ConfigureServices((context, services) =>
{
services.AddHangfire((provider, configuration) => configuration
.UseSqlServerStorage(context.Configuration.GetConnectionString("Hangfire"))
.UseCronitor(provider));
services.AddHangfireServer();
})
.Build()
.RunAsync();
AddHangfire() and AddHangfireServer() come from Hangfire's own Hangfire.NetCore package (or Hangfire.AspNetCore).
Without dependency injection
Configure the static CronitorClient first, then call UseCronitor():
using Cronitor;
using Cronitor.Hangfire;
using Hangfire;
CronitorClient.Configure("apiKey");
GlobalConfiguration.Configuration
.UseSqlServerStorage("connectionString")
.UseCronitor();
Monitor keys
A recurring job reports to the monitor with the same key as its ID, so name your recurring jobs after their Cronitor monitors:
RecurringJob.AddOrUpdate("nightly-backup", () => Backup.Run(), Cron.Daily(3));
Cronitor doesn't accept / in a monitor key, so a / in the ID becomes -: a recurring job reports/daily reports to reports-daily. Recurring jobs reports/daily and reports-daily would therefore share a monitor; rename one of them to keep them apart. A monitor key can be at most 100 characters: a recurring job whose key would be longer isn't reported or synced, and the reason is logged.
Jobs that are not recurring, such as those started with BackgroundJob.Enqueue(), are not reported.
Retries
When a recurring job fails, Hangfire retries it by default, often minutes or hours later. Each attempt is reported as its own run, and a retry's fail message ends with its attempt, for example Disk is full (attempt 2). A job that fails twice and then succeeds is therefore reported as two failed runs followed by a completed one.
A job that stops when its server shuts down, or that is deleted while it runs, isn't reported as failed. Its run is abandoned with the message The service went offline or The job was aborted, so a deploy or restart doesn't make the monitor fail, and Cronitor keeps the run open until the job runs again; Hangfire runs a job interrupted by a shutdown again once a server is back. This needs the job to take a CancellationToken and stop when it's cancelled; a job that ignores it either finishes, or is left by Hangfire after its shutdown timeout without being reported.
Schedules
A monitor created by a job's first report has no schedule, so Cronitor alerts when the job fails but not when it doesn't run at all. To give each recurring job's monitor the job's schedule and time zone, add schedule sync:
services.AddHangfireServer();
services.AddCronitorHangfireScheduleSync();
Once the application has started, the recurring jobs in Hangfire's storage are sent to Cronitor in one request, in the background. Only the schedule and time zone are set; everything else on the monitor, such as its name and alerts, is kept. Recurring jobs added later get their schedule at the next start.
A schedule is only synced when Cronitor reads it the same way as Hangfire. A cron expression with a seconds field is synced without it when the seconds are 0; one Cronitor doesn't support, such as the nearest weekday (15W), or one that restricts both the day of the month and the day of the week (Hangfire then needs both to match, Cronitor either), isn't synced, and the reason is logged. Recurring jobs that share a monitor key share its schedules, as long as they run in the same time zone. Schedule sync needs dependency injection.
Errors
Reporting never affects your jobs: the start of a job is reported in the background, and the worker waits at most five seconds for its end to be reported. If Cronitor is slower than that, the worker moves on and the report continues in the background, so a report still pending when the application stops can be lost. If a report can't be sent, the job still runs and keeps its result, and the error is logged through the host's logging.
For everything else about the Cronitor client, such as logging and the API key, see the Cronitor README.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Cronitor (>= 2026.2.78)
- Hangfire.Core (>= 1.8.25 && < 2.0.0)
- Newtonsoft.Json (>= 13.0.4)
-
net10.0
- Cronitor (>= 2026.2.78)
- Hangfire.Core (>= 1.8.25 && < 2.0.0)
- Newtonsoft.Json (>= 13.0.4)
-
net8.0
- Cronitor (>= 2026.2.78)
- Hangfire.Core (>= 1.8.25 && < 2.0.0)
- Newtonsoft.Json (>= 13.0.4)
-
net9.0
- Cronitor (>= 2026.2.78)
- Hangfire.Core (>= 1.8.25 && < 2.0.0)
- Newtonsoft.Json (>= 13.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.