---
title: "Crons"
description: "Sentry Crons allows you to monitor the uptime and performance of any scheduled, recurring job in your application."
url: https://docs.sentry.io/platforms/dotnet/guides/log4net/crons/
---

# Set Up Crons | Sentry for log4net

Once implemented, it'll allow you to get alerts and metrics to help you solve errors, detect timeouts, and prevent disruptions to your service.

If you are using [Hangfire](https://www.hangfire.io/), please see [how to setup monitoring for Hangfire jobs](https://docs.sentry.io/platforms/dotnet/guides/log4net/crons/hangfire.md).

## [Requirements](https://docs.sentry.io/platforms/dotnet/guides/log4net/crons.md#requirements)

* Use our [getting started](https://docs.sentry.io/platforms/dotnet/guides/log4net.md) guide to install and configure the Sentry .NET SDK (min 4.2.0) for your recurring job.
* [Create and configure](https://sentry.io/issues/alerts/new/crons/) your first Monitor.

## [Check-Ins (Recommended)](https://docs.sentry.io/platforms/dotnet/guides/log4net/crons.md#check-ins-recommended)

Check-in monitoring allows you to track a job's progress by completing two check-ins: one at the start of your job and another at the end of your job. This two-step process allows Sentry to notify you if your job didn't start when expected (missed) or if it exceeded its maximum runtime (failed).

```csharp
// 🟡 Notify Sentry your job is running:
var checkInId = SentrySdk.CaptureCheckIn("<monitor-slug>", CheckInStatus.InProgress);

// Execute your scheduled task here...

// 🟢 Notify Sentry your job has completed successfully:
SentrySdk.CaptureCheckIn("<monitor-slug>", CheckInStatus.Ok, checkInId);
```

If your job execution fails, you can notify Sentry about the failure:

```csharp
// 🔴 Notify Sentry your job has failed:
SentrySdk.CaptureCheckIn("<monitor-slug>", CheckInStatus.Error, checkInId);
```

## [Heartbeat](https://docs.sentry.io/platforms/dotnet/guides/log4net/crons.md#heartbeat)

Heartbeat monitoring notifies Sentry of a job's status through one check-in. This setup will only notify you if your job didn't run when expected (missed). If you want to monitor job timeouts, use the `InProgress` check-ins as indicated in the previous section.

```csharp
// Execute your scheduled task...

// 🟢 Notify Sentry your job completed successfully:
SentrySdk.CaptureCheckIn(
    "<monitor-slug>",
    CheckInStatus.Ok,
    // Optionally annotate the check-in with the job duration
    duration: TimeSpan.FromSeconds(10)
);
```

If your job execution fails, you can:

```csharp
// 🔴 Notify Sentry your job has failed:
SentrySdk.CaptureCheckIn(
    "<monitor-slug>",
    CheckInStatus.Error,
    duration: TimeSpan.FromSeconds(10)
);
```

## [Upserting Cron Monitors](https://docs.sentry.io/platforms/dotnet/guides/log4net/crons.md#upserting-cron-monitors)

You can create and update your Monitors programmatically with code rather than [creating and configuring them in Sentry.io](https://sentry.io/issues/alerts/new/crons/).

```csharp
// 🟡 Notify Sentry your job is running:
var checkInId = SentrySdk.CaptureCheckIn(
    "<monitor-slug>",
    CheckInStatus.InProgress,
    configureMonitorOptions: options =>
    {
        // Use a crontab schedule (every 10 minutes)
        options.Interval("*/10 * * * *");
        options.CheckInMargin = TimeSpan.FromMinutes(5);
        options.MaxRuntime = TimeSpan.FromMinutes(15);
        options.TimeZone = "Europe/Vienna";
        options.FailureIssueThreshold = 2;
        options.RecoveryThreshold = 5;
    });

// Execute your scheduled task here...

// 🟢 Notify Sentry your job has completed successfully:
SentrySdk.CaptureCheckIn("<monitor-slug>", CheckInStatus.Ok, checkInId);
```

Alternatively, you can use an interval schedule:

```csharp
// 🟡 Notify Sentry your job is running:
var checkInId = SentrySdk.CaptureCheckIn(
    "<monitor-slug>",
    CheckInStatus.InProgress,
    configureMonitorOptions: options =>
    {
        // Use an interval schedule (every 10 minutes)
        options.Interval(10, SentryMonitorInterval.Minute);
        options.CheckInMargin = TimeSpan.FromMinutes(5);
        options.MaxRuntime = TimeSpan.FromMinutes(15);
        options.TimeZone = "Europe/Vienna";
    });

// Execute your scheduled task here...

// 🟢 Notify Sentry your job has completed successfully:
SentrySdk.CaptureCheckIn("<monitor-slug>", CheckInStatus.Ok, checkInId);
```

Supported units are:

* `SentryMonitorInterval.Minute`
* `SentryMonitorInterval.Hour`
* `SentryMonitorInterval.Day`
* `SentryMonitorInterval.Week`
* `SentryMonitorInterval.Month`
* `SentryMonitorInterval.Year`

## [Alerts](https://docs.sentry.io/platforms/dotnet/guides/log4net/crons.md#alerts)

When your recurring job fails to check in (missed), runs beyond its configured maximum runtime (failed), or manually reports a failure, Sentry will create an error event with a tag to your monitor.

To receive alerts about these events:

1. Navigate to **Alerts** in the sidebar.
2. Create a new alert and select "Issues" under "Errors" as the alert type.
3. Configure your alert and define a filter match to use: `The event's tags match {key} {match} {value}`.

Example: `The event's tags match monitor.slug equals my-monitor-slug-here`

Learn more in [Issue Alert Configuration](https://docs.sentry.io/product/alerts/create-alerts/issue-alert-config.md).

## [Rate Limits](https://docs.sentry.io/platforms/dotnet/guides/log4net/crons.md#rate-limits)

To prevent abuse and resource overuse, Crons limits check-ins to **6 per minute for each monitor environment**.

For example, if you have a monitor called "database-backup" with two environments:

* `database-backup` in environment `production` can send up to 6 check-ins per minute
* `database-backup` in environment `staging` can also send up to 6 check-ins per minute
* Combined, they can send up to 12 check-ins per minute

You can verify if any check-ins are being dropped by visiting the [Usage Stats](https://docs.sentry.io/product/stats.md#usage-stats) page. To avoid dropped check-ins, ensure your monitors don't exceed the rate limit.

## Pages in this section

- [Hangfire](https://docs.sentry.io/platforms/dotnet/guides/log4net/crons/hangfire.md)
