CronNudge

Published October 21, 2026

How to Monitor Hangfire Recurring Jobs

A recurring job fires only while a Hangfire server is running. The web app can answer requests, and the method can still never run. Nothing in that process emails you. A ping after the work is the alert for that silence.

The scheduling facts below are from the Hangfire documentation and the Hangfire 1.8 source. A Linux crontab on a machine you run is crontab not running. Two copies of the same work are prevent overlapping cron jobs. A process inside a container is cron in Docker, and a Kubernetes CronJob is a different scheduler, covered in Kubernetes CronJobs. An Azure Functions timer is NCRONTAB on the Functions host, not Hangfire, and that page is Azure Functions timer triggers. The five fields are in cron expression examples. The general pattern is how to monitor cron jobs.

The server has to be running

AddOrUpdate writes a row in storage. A component inside Hangfire Server reads those rows and enqueues them as background jobs. The ASP.NET Core integration starts that server with AddHangfireServer, which registers it as an IHostedService. new BackgroundJobServer() is the same server in a console app or a Windows service. The object has to stay alive. Disposing it stops processing.

AddHangfire alone configures storage. It does not start a server. A site that only enqueues, and never calls AddHangfireServer or constructs a BackgroundJobServer, stores the recurring row and runs nothing.

builder.Services.AddHangfire(configuration => configuration
    .SetDataCompatibilityLevel(CompatibilityLevel.Version_180)
    .UseSimpleAssemblyNameTypeSerializer()
    .UseRecommendedSerializerSettings()
    .UseSqlServerStorage(builder.Configuration.GetConnectionString("HangfireConnection")));

builder.Services.AddHangfireServer();

IsLightweightServer leaves the workers and skips the recurring scheduler. If every server is constructed that way, recurring rows are never enqueued.

On IIS, the Hangfire deployment page says the server inside a web app does not start until the first request, and Idle Timeout plus app-pool recycling bring the process down. While it is down, recurring tasks are not enqueued and enqueued jobs are not processed. For ASP.NET Core on IIS, that page says set the pool start mode to Always Running and Idle Time-out to 0, and preload the application. On Azure App Service, the same page says turn on Always On, and that this setting does not work for free sites. A container that exits, or a pod that is not running, is the same silence. The process has to stay up.

The dashboard is served by the web app. By default only local requests can open it. The Recurring Jobs page lists each id with its cron, time zone, next execution, and last execution. An empty next execution with no error is shown as Disabled. An empty next execution with an error is shown as Error. Last execution is N/A until a run has been enqueued. That page is not an alert. CronNudge does not read it.

Registering the recurring job

RecurringJob.AddOrUpdate creates the row or updates the row with the same id. RecurringJob is a facade over IRecurringJobManager, which AddHangfire registers. Use one stable id. A second id is a second schedule. Identifiers can be case-sensitive, depending on the storage.

Overloads that omit the id, and overloads that take a TimeZoneInfo plus a queue string instead of RecurringJobOptions, are marked obsolete and are slated for removal in 2.0.0. RecurringJobOptions.QueueName is obsolete for the same reason. Pass the queue as its own argument. Call this after Hangfire is configured, on startup, with the same id every time so a restart updates the row.

var app = builder.Build();

using (var scope = app.Services.CreateScope())
{
    var manager = scope.ServiceProvider.GetRequiredService<IRecurringJobManager>();
    manager.AddOrUpdate<NightlyReport>(
        "nightly-report",
        job => job.Run(),
        Cron.Daily(3),
        new RecurringJobOptions { TimeZone = TimeZoneInfo.Utc });
}

app.Run();

RemoveIfExists deletes that id and does not throw when the id is already gone. Changing the id in code leaves the old row in place until you remove it, and the old row keeps its schedule. Trigger runs the job now. The docs say that invocation is not recorded on the recurring row, and the next execution time is not recalculated from it. A weekly job triggered on Friday still has next execution on the following Wednesday.

Hangfire.AspNetCore sets the job activator to AspNetCoreJobActivator. That activator creates the class with ActivatorUtilities.GetServiceOrCreateInstance, so a constructor can take IHttpClientFactory and IConfiguration without a separate AddTransient for the job class.

Cron expressions and time zones

Hangfire parses cron with Cronos. Five fields are the default. Six fields turn on seconds, and the seconds field is first. Anything else throws. A string that starts with @ is a Cronos macro.

┌───────────── second (optional, only when there are six fields)
│ ┌───────────── minute (0-59)
│ │ ┌───────────── hour (0-23)
│ │ │ ┌───────────── day of month (1-31)
│ │ │ │ ┌───────────── month (1-12 or JAN-DEC)
│ │ │ │ │ ┌───────────── day of week (0-7, or SUN-SAT)
│ │ │ │ │ │          (0 or 7 is Sunday)
│ │ │ │ │ │
* * * * * *

*, lists, ranges, and / steps work in every field. Month and weekday names are the first three letters. Cronos also accepts L, W, #, and ? as a synonym of *. When both the day-of-month and the day-of-week are restricted, Cronos requires both to match. Linux cron treats that pair as either. Do not copy that expression onto the check until the cron tool lists the days you meant.

RecurringJobOptions.TimeZone defaults to TimeZoneInfo.Utc. The cron text does not contain the zone. Cron.Daily and the other helpers document their clock as UTC because that default is UTC. Set TimeZone to change the zone without changing the five fields, and put the same zone on the check. The id has to be one TimeZoneInfo.FindSystemTimeZoneById accepts on that host. The check wants an IANA name such as America/New_York.

Cronos moves a fixed time that lands in a spring-forward gap to the next valid time, so that occurrence is not dropped. On the repeated hour in the fall, a fixed time runs once, and an interval expression runs on both passes. The other schedulers are in cron jobs and daylight saving time.

These helpers return five fields:

Call Expression
Cron.Minutely() * * * * *
Cron.Hourly() 0 * * * *
Cron.Daily() 0 0 * * *
Cron.Daily(3) 0 3 * * *
Cron.Weekly() 0 0 * * 1
Cron.Monthly() 0 0 1 * *
Cron.Yearly() 0 0 1 1 *
Cron.MinuteInterval(15) */15 * * * *
Cron.Never() 0 0 31 2 *

Cron.Weekly() is Monday, because DayOfWeek.Monday is 1. The Cronos macro @weekly is Sunday, 0 0 * * 0. @daily and Cron.Daily() are both midnight. Cron.Daily(3) is 03:00, not midnight. Cron.Never() is February 31, which never occurs. MinuteInterval only lines up with the clock when 60 divides the interval. 15 does. 7 does not.

H is a Cronos jitter mark. Hangfire calls CronExpression.Parse without a jitter seed, and Cronos throws when H is used without one. That recurring row then fails to schedule.

Save five fields on the check, minute first. When the Hangfire expression has six fields and the seconds field is 0, drop that leading 0. 0 */15 * * * * becomes */15 * * * *. A seconds step such as */10 * * * * * is every ten seconds. That is under Free's 5-minute minimum and under Pro's 1-minute minimum, so it cannot be a check at that cadence.

The server polls on SchedulePollingInterval. That option defaults to 15 seconds. When the interval is greater than zero, the scheduler waits that long after a pass. The recurring scheduler's remarks still describe a one-minute wait. That branch is the one used when the interval is zero, which is not what BackgroundJobServer passes. A six-field expression can name a seconds cadence, and the default server still only looks every 15 seconds. Lowering the interval makes the poll faster. It does not make a sub-minute cadence a valid check.

Queues and workers

The default queue name is default. A new server listens only to that queue. WorkerCount starts at the lesser of the processor count times 5 and 20, and it has to be at least 1. Workers fetch jobs from the queues in Queues, and from no others.

builder.Services.AddHangfireServer(options =>
{
    options.Queues = new[] { "default", "reports" };
});

Put the job on reports with the queue argument. QueueAttribute on the method is the other way. A queue name is lowercase letters, digits, underscore, and dash. Reports does not pass that check.

manager.AddOrUpdate<NightlyReport>(
    "nightly-report",
    "reports",
    job => job.Run(),
    "0 9 * * 1-5",
    new RecurringJobOptions
    {
        TimeZone = TimeZoneInfo.FindSystemTimeZoneById("America/New_York"),
    });

A job whose queue is missing from every server's Queues stays Enqueued. No worker takes it. The recurring row can still show a last execution, and that execution is not a success. A full worker pool is the other wait: the job is on a queue someone listens to, and every worker is already busy. Raise WorkerCount when the jobs should run beside each other. The wrong queue is not fixed by more workers.

Retries and failures

AutomaticRetryAttribute is a global filter. DefaultRetryAttempts is 10. The delay grows with the attempt and includes a random term. The default function waits at least 15 seconds, so the spacing is not a fixed list of round minutes. While an attempt remains, the filter moves the job to the Scheduled state instead of leaving it failed. A delay of zero enqueues it immediately. The default delay is not zero.

That scheduled retry is not a success. The dashboard will show the retry. The method has not completed.

OnAttemptsExceeded defaults to AttemptsExceededAction.Fail, which leaves the job in the Failed state. You can retry a Failed job manually. The exceptions page says a Failed job is not expired unless you delete it. AttemptsExceededAction.Delete moves the job to Deleted instead, including when Attempts is 0 and retries are disabled. Attempts = 0 on the method, or a global filter with a different Attempts, changes the count. The attribute remarks also say a job can still run more than once after a shutdown, because processing is at least once even when retries are off.

An exception in the method skips every line after the throw. A ping written after the work does not run for that attempt.

If scheduling the recurring row itself throws, including a cron string Cronos rejects, the scheduler retries that row up to 5 times and then disables it, clearing the next execution and storing the error. The Recurring Jobs page shows Error for that cell. The method is not called.

Multiple servers and overlap

Every non-lightweight server runs a recurring scheduler. The schedulers take a distributed lock around the pass. If this server does not get the lock, another server is doing that pass. The remarks on the scheduler say the extra instances are for failover, not for more throughput. One pass enqueues the work.

MisfireHandling is on RecurringJobOptions in Hangfire 1.8, and it defaults to MisfireHandlingMode.Relaxed. Relaxed creates a single background job no matter how many occurrences were missed while no server was running. The time on that job is the time it was scheduled, not each missed tick. Strict creates one background job per missed occurrence. Ignorable skips a missed schedule. The scheduler still enqueues an occurrence that falls inside its precision window, which is twice the polling interval: 30 seconds when the poll is the default 15 seconds. A downtime that ends with no server coming back still enqueues nothing.

The background job that was enqueued can still execute more than once. The automatic-retry remarks say a job can run several times after a shutdown even when that filter is disabled, because processing is at least once. Two recurring ids for the same method are two schedules, and both run. Trigger is an extra run on top of the schedule.

DisableConcurrentExecution is the filter Hangfire ships for one method. The constructor takes the wait in seconds and rejects a negative value. There is no default timeout. On the way in, it acquires a distributed lock. The default resource is the job type and method name. A resource format string, filled from the job arguments, is the other constructor. The lock is released when the method finishes. If the wait expires, that attempt fails, and AutomaticRetry will try again unless you turned retries off.

[DisableConcurrentExecution(600)]
public async Task Run()
{
    await DoWork();
}

600 is an example for a job that should wait up to ten minutes, not a Hangfire default. The concurrency page says this filter depends on an active storage connection, and the lock can be released if that connection breaks, without telling the method. It narrows overlapping runs. It does not prove a second execution is impossible. A second server is not a second schedule. It is another worker that can pick up the one enqueued job, or run it again if Hangfire re-queues it.

What leaves no successful ping

  • No Hangfire server is running. AddHangfire without AddHangfireServer, a disposed BackgroundJobServer, or a process that has exited.
  • IIS idle timeout or an app-pool recycle stopped the worker, or the Azure site is on a free plan where Always On does not apply.
  • Every server is lightweight, so none of them run the recurring scheduler.
  • The id was never registered, RemoveIfExists deleted it, or the code now uses a new id and the old one is the one you removed.
  • The cron never occurs. Cron.Never() is February 31. The next execution cell shows Disabled.
  • Scheduling the row threw, five times. The next execution cell shows Error, and the method is not called.
  • The job is on a queue no server lists. It stays Enqueued.
  • Every worker is busy. The job is still waiting.
  • The method throws before the success ping. A retry is Scheduled, not a success. Failed and Deleted are what remain after the attempts are used.
  • DisableConcurrentExecution is still waiting, or the wait expired and that attempt failed.
  • No server was up for the occurrence. Relaxed enqueues one job when a server returns. Ignorable skips the missed schedule, except an occurrence still inside the precision window.
  • The work failed in a process that never sent /fail or ?exit=.

CronNudge does not read Hangfire storage, the dashboard, or the logs, and it cannot retry, trigger, or delete a job. It only knows about pings it receives. The job page is still where the exception shows up.

Ping after the work succeeds

The success URL is https://cronnudge.com/ping/YOUR_ID. GET, POST, and HEAD all count. A stored ping answers ok with Cache-Control: no-store. YOUR_ID is the id in the ping URL, not the badge id. Anyone with that URL can send a ping. Keep the value free of a query string and of /start or /fail.

Do not hard-code it. Set the environment variable CRONNUDGE_URL. On the default host, IConfiguration reads that variable. If it is missing, this job does not start the work.

The ping is the last step. AddHttpClient plus IHttpClientFactory is the client when the ASP.NET Core activator constructs the class. A static HttpClient is the alternative when there is no service provider: one instance for the process, not new HttpClient() on each run. A failure to send is caught so a monitoring hiccup does not fail a method that already finished. The ping is still missed, and the check alerts after grace.

builder.Services.AddHttpClient("cronnudge", client =>
{
    client.Timeout = TimeSpan.FromSeconds(10);
});
public class NightlyReport
{
    private readonly IHttpClientFactory _httpClientFactory;
    private readonly string _cronnudgeUrl;

    public NightlyReport(IHttpClientFactory httpClientFactory, IConfiguration configuration)
    {
        _httpClientFactory = httpClientFactory;
        _cronnudgeUrl = configuration["CRONNUDGE_URL"] ?? "";
        if (string.IsNullOrWhiteSpace(_cronnudgeUrl))
        {
            throw new InvalidOperationException("CRONNUDGE_URL is not set.");
        }
    }

    public async Task Run()
    {
        try
        {
            await DoWork();
            await Send(Base(), null);
        }
        catch (Exception)
        {
            await Send(Base() + "/fail", Guid.NewGuid().ToString("N"));
            throw;
        }
    }

    private string Base()
    {
        var trimmed = _cronnudgeUrl.Split('?', 2)[0].TrimEnd('/');
        return trimmed;
    }

    private async Task Send(string url, string? idempotencyKey)
    {
        try
        {
            var client = _httpClientFactory.CreateClient("cronnudge");
            using var request = new HttpRequestMessage(HttpMethod.Get, url);
            if (idempotencyKey != null)
            {
                request.Method = HttpMethod.Post;
                var key = idempotencyKey.Length > 128 ? idempotencyKey.Substring(0, 128) : idempotencyKey;
                request.Headers.TryAddWithoutValidation("Idempotency-Key", key);
            }
            using var response = await client.SendAsync(request);
        }
        catch (Exception ex)
        {
            Console.Error.WriteLine("heartbeat ping failed: " + ex.Message);
        }
    }

    private Task DoWork() => Task.CompletedTask;
}

Without the factory, keep one client for the life of the process and read the same variable:

private static readonly HttpClient Http = new HttpClient
{
    Timeout = TimeSpan.FromSeconds(10),
};

var url = Environment.GetEnvironmentVariable("CRONNUDGE_URL");

Pass the exit code

?exit= accepts an integer from 0 to 255. 0 is a success. 1 through 255 marks the check down immediately when it was not already down. Anything else is ignored, and the ping stays a success. Use this or /fail, not both.

public async Task Run()
{
    int code;
    try
    {
        code = await DoWork();
    }
    catch (Exception)
    {
        await Send(Base() + "/fail", Guid.NewGuid().ToString("N"));
        throw;
    }

    await Send(Base() + "?exit=" + code, null);
    if (code != 0) throw new InvalidOperationException("work failed: " + code);
}

/fail is the same immediate down alert. A paused check stores the ping and does not alert. A second failure while the check is already down does not send another alert. One alert when it goes down, and one when a later success recovers it.

The throw is what Hangfire records. Swallowing the exception means the method returned without an exception, so Hangfire moves that attempt to the Succeeded state. The lines that would have pinged success never ran unless you sent them yourself.

What a retry does to the alert

The default is 10 retry attempts. Each attempt that throws enters the catch and sends /fail. The first /fail while the check is up is the down alert. Later /fail pings, while the check is already down, do not send another alert. A new idempotency key is required for each of those pings. The key is cut at 128 characters and matched per check. A repeated key is a replay. It does not record a second ping and it does not send a second alert.

If a later attempt reaches the success ping, that success is the recovery, even though earlier attempts failed. The job is healthy in Hangfire only after that success. If every attempt fails, you still have one down alert, and the job ends Failed or Deleted according to OnAttemptsExceeded.

Skipping /fail is the other choice. The check stays up until grace passes with no success ping. Attempts that finish inside grace, and then succeed, do not alert. Attempts that outlast grace alert on the missed success, and the late success is the recovery. A method that never starts never enters the catch. The missed success ping is the alert after grace.

/start and a max runtime

/start records a start. It is not a success. Turn on "Track start and finish," or set Max runtime (seconds), which turns run tracking on. A second /start while a run is open is an overlap alert and does not close the first run. A success or /fail closes the open runs. Two success pings alone do not raise an overlap alert.

Use one idempotency key for this start and a different key for the finish. A retry is a new attempt. If the previous attempt's /fail closed the run, the next /start opens a new one. If the /fail never arrived, the retry's /start is a second start while the run is still open.

public async Task Run()
{
    var id = Guid.NewGuid().ToString("N");
    await Send(Base() + "/start", id + "-start");
    await DoWork();
    await Send(Base(), id + "-ok");
}

The success ping still has to run after the work. Max runtime is 1 second through 7 days. With a run open and a max runtime set, the deadline becomes that start plus the max runtime. It is not the earlier of that and the schedule. No finish means one stuck alert, once for that start, and the check goes down. A later success is the recovery. With run tracking and no max runtime, an open run is due at the earlier of the schedule deadline and the start plus grace. The grace used for that run is at least 60 seconds. The alert is down, not stuck. A method that never starts never calls /start, so it cannot go stuck. Silence until the schedule deadline is the alert. Free includes run tracking on 3 checks. Pro removes that cap. Details are in assertions, runs, and agents.

Set max runtime a little past the longest healthy run. Hangs are in cron job stuck or hanging.

Match the check to the schedule

Five Hangfire fields are already the check, minute first. Drop a leading 0 seconds field when the expression has six. Set the check timezone to RecurringJobOptions.TimeZone. The cron tool lists the next runs before grace is added.

The form's periods are 5 minutes, 15 minutes, 30 minutes, 1 hour, 6 hours, 1 day, and 1 week. Grace is none, 1 minute, 5 minutes (the default), 15 minutes, or 1 hour. Anything else, from the plan minimum up to 31 days for an interval and from 0 through 7 days for grace, is an API value, and the API is on Pro. Creating a check sets the first deadline from that moment. A success then moves the deadline. An interval counts from the last success. A cron expression uses the next occurrence after that success, then adds grace. An interval check stores UTC. The timezone field on the form is for cron.

Every night at 03:00 UTC. Cron.Daily(3) is 0 3 * * *, and the default TimeZone is UTC. Check 0 3 * * *, timezone UTC. A success at 03:02 is inside the default 5 minutes of grace. The next deadline is 03:05 the next night. A run that never pings alerts at 03:05. Cron.Daily() and @daily are midnight, 0 0 * * *, not 03:00.

Weekdays at 09:00 in New York. Hangfire 0 9 * * 1-5 with TimeZone set to the host's id for that zone. Check 0 9 * * 1-5 in America/New_York. Monday is 1 and Friday is 5. A success at 09:02 is inside the default grace. The next deadline is 09:05 on the next weekday. Saturday and Sunday are not expected. Sunday is 0 or 7.

Every 15 minutes. Cron.MinuteInterval(15) is */15 * * * *. Check */15 * * * *. The gap is 15 minutes, which is longer than Free's 5-minute minimum, so it is a Free check. It fires on :00, :15, :30, and :45. A 15-minute interval check counts from the last success and stores UTC. Use the cron when the Hangfire expression is a cron. A six-field 0 */15 * * * * is the same minutes at second 0. Drop the leading 0.

Every minute. Cron.Minutely() is * * * * *. Check * * * * *. It is valid cron, and it is not a Free check. Pro's minimum is 1 minute.

Every ten seconds. */10 * * * * * is six fields, so Cronos reads a seconds field. The gap is 10 seconds. That is under Free's 5-minute minimum and under Pro's 1-minute minimum. It cannot be a check at that cadence. The default poll is 15 seconds, and the default misfire mode collapses missed ticks into one enqueued job, so the default server is not running that method every ten seconds either.

Free is 10 checks, a 5-minute minimum interval, email plus one Slack or Discord channel, and run tracking on 3 checks. Pro is $12 a month for 100 checks, a 1-minute minimum, signed webhooks, and the API. Details are on pricing.

FAQ

Why is a Hangfire recurring job not running? The usual cause is that no Hangfire server is running. AddHangfire stores the row. AddHangfireServer, or a BackgroundJobServer that stays alive, is what enqueues and runs it. On IIS, idle timeout and an app-pool recycle stop that process. The cron can also be one that never occurs, such as February 31, or the scheduler can disable the row after five scheduling errors. A job on a queue no server lists stays Enqueued.

Why does a Hangfire job run twice? Each server runs a scheduler, and a distributed lock means one of them enqueues the occurrence. The default misfire mode creates one background job for a stretch of missed ticks, not one per tick. That background job can still execute more than once, because processing is at least once across shutdown and retry. Two recurring ids, or Trigger now, are extra runs. DisableConcurrentExecution waits for a distributed lock for the timeout you pass. The lock can drop if the storage connection breaks.

How do Hangfire cron and time zones become a check? Hangfire uses Cronos. Five fields are minute, hour, day of month, month, day of week. Six fields put seconds first. Drop a leading 0 and save the other five. The time zone is RecurringJobOptions.TimeZone, and the default is UTC. Put that same zone on the check. Cron.Daily(3) is 0 3 * * *, not midnight. A seconds step such as every ten seconds is finer than Free's 5-minute minimum and Pro's 1-minute minimum, so it cannot be a check at that cadence.

Does a missed occurrence run after downtime? Only once a server is back, and only according to MisfireHandling. The 1.8 default is Relaxed: one background job, no matter how many occurrences were missed. Strict creates one job per missed occurrence. Ignorable skips the missed schedule, except an occurrence that is still inside the scheduler's precision window, twice the polling interval. Until some non-lightweight server is running, nothing is enqueued.

Does a failed or retrying job alert immediately? Only if a ping is sent. The default is 10 retry attempts, and each attempt that throws can send /fail. The first /fail while the check is up is one down alert. Later /fail pings while the check is already down do not send another. A success on a later attempt is the recovery. A retry that is still Scheduled is not a success. With no /fail, the missed success ping is the alert after grace. A method that never starts never reaches the catch.

Can CronNudge see the Hangfire dashboard or retry a job? No. It does not read Hangfire storage, the dashboard, or the logs, and it cannot retry, trigger, or delete a job. It only knows about pings it receives. The Recurring Jobs page is still where next execution, last execution, and the exception show up.


The scheduler enqueues the job. A worker has to finish it. The ping is how you hear about the occurrence that never called home. Create the check, or read the five fields on the cron tool. Related: how to monitor cron jobs, crontab not running, cron expression examples, prevent overlapping cron jobs, cron in Docker, Kubernetes CronJobs, and Azure Functions timer triggers.