Repository navigation
Schedules and assertions
Build a monitor's schedule and assertions without writing raw cron or assertion strings.
Schedule (Cronitor.Scheduling) and Assertion (Cronitor.Assertions) are fluent builders for a monitor's Schedule and Assertions. Each builder produces the same string you could write yourself, so raw strings still work wherever a builder does.
A schedule tells Cronitor when to expect telemetry from a job or heartbeat, or how often to request a check. It's a cron expression or an interval:
using Cronitor.Models.Monitors;
using Cronitor.Scheduling;
var job = new Job("nightly-backup")
{
Schedule = Schedule.Cron.Daily(hour: 3)
};Schedule sets a single schedule. To set several, use Schedules:
using Cronitor.Models.Monitors;
using Cronitor.Scheduling;
var job = new Job("reports")
{
Schedules = new[]
{
Schedule.Cron.Daily(hour: 6),
Schedule.Cron.Daily(hour: 18)
}
};Schedule.Cron has the common cron schedules. Times are in the monitor's Timezone.
| Method | Produces | Runs |
|---|---|---|
EveryMinute() |
* * * * * |
Every minute |
EveryHour(minute: 15) |
15 * * * * |
Every hour, at the given minute (default 0) |
Daily(hour: 3, minute: 30) |
30 3 * * * |
Every day, at the given time (default midnight) |
Weekly(day: 1, hour: 8) |
0 8 * * 1 |
Every week, on the given day of the week (0 is Sunday) |
Monthly(day: 1, hour: 2) |
0 2 1 * * |
Every month, on the given day of the month |
Yearly(month: 12, day: 31, hour: 23) |
0 23 31 12 * |
Every year, on the given date |
Expression("0 */6 * * 1-5") |
0 */6 * * 1-5 |
Any cron expression, used as it is |
Schedule.Cron.Create() builds a cron expression field by field. Fields you don't set are *. Finish with Build():
using Cronitor.Scheduling;
// every 15 minutes, 8:00–17:59, Monday to Friday: */15 8-17 * * 1-5
var schedule = Schedule.Cron.Create()
.MinuteEvery(15)
.HourRange(8, 17)
.DayOfWeekRange(1, 5)
.Build();| Field | Value | Step | Range |
|---|---|---|---|
| Minute |
Minute(int) or Minute(string)
|
MinuteEvery(step) |
MinuteRange(from, to) |
| Hour |
Hour(int) or Hour(string)
|
HourEvery(step) |
HourRange(from, to) |
| Day of month |
DayOfMonth(int) or DayOfMonth(string)
|
DayOfMonthRange(from, to) |
|
| Month |
Month(int) or Month(string)
|
MonthRange(from, to) |
|
| Day of week |
DayOfWeek(int) or DayOfWeek(string)
|
DayOfWeekRange(from, to) |
The string overloads take anything cron accepts in that field, such as a list: `.DayOfM
Getting started
Telemetry
Management
Integrations