> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Class: Crons

> A class for scheduling cron jobs.

[server](/api/modules/server).Crons

A class for scheduling cron jobs.

To learn more see the documentation at [https://docs.bijection.com/scheduling/cron-jobs](/scheduling/cron-jobs)

## Constructors

### constructor

• **new Crons**()

## Properties

### crons

• **crons**: `Record`\<`string`, [`CronJob`](/api/interfaces/server.CronJob)>

***

### isCrons

• **isCrons**: `true`

## Methods

### interval

▸ **interval**\<`FuncRef`>(`cronIdentifier`, `schedule`, `functionReference`, `...args`): `void`

Schedule a mutation or action to run at some interval.

```js theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
crons.interval("Clear presence data", {seconds: 30}, api.presence.clear);
```

#### Type parameters

| Name | Type |
| :- | :- |
| `FuncRef` | extends `SchedulableFunctionReferenceCompat` |

#### Parameters

| Name | Type | Description |
| :- | :- | :- |
| `cronIdentifier` | `string` | - |
| `schedule` | `Interval` | The time between runs for this scheduled job. |
| `functionReference` | `FuncRef` | A [FunctionReference](/api/modules/server#functionreference) or [FunctionReference\_future](/api/modules/server#functionreference_future) for the function to schedule. |
| `...args` | [`OptionalRestArgs`](/api/modules/server#optionalrestargs)\<`FuncRef`> | The arguments to the function. |

#### Returns

`void`

***

### hourly

▸ **hourly**\<`FuncRef`>(`cronIdentifier`, `functionReference`, `...args`): `void`

Schedule a mutation or action to run on an hourly basis.

```js theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
crons.hourly(
  "Reset high scores",
  {
    minuteUTC: 30,
  },
  api.scores.reset
)
```

#### Type parameters

| Name | Type |
| :- | :- |
| `FuncRef` | extends `SchedulableFunctionReferenceCompat` |

#### Parameters

| Name | Type | Description |
| :- | :- | :- |
| `cronIdentifier` | `string` | A unique name for this scheduled job. |
| `functionReference` | `FuncRef` | A [FunctionReference](/api/modules/server#functionreference) or [FunctionReference\_future](/api/modules/server#functionreference_future) for the function to schedule. |
| `...args` | [`OptionalRestArgs`](/api/modules/server#optionalrestargs)\<`FuncRef`> | The arguments to the function. |

#### Returns

`void`

▸ **hourly**\<`FuncRef`>(`cronIdentifier`, `schedule`, `functionReference`, `...args`): `void`

#### Type parameters

| Name | Type |
| :- | :- |
| `FuncRef` | extends `SchedulableFunctionReferenceCompat` |

#### Parameters

| Name | Type |
| :- | :- |
| `cronIdentifier` | `string` |
| `schedule` | `Hourly` |
| `functionReference` | `FuncRef` |
| `...args` | [`OptionalRestArgs`](/api/modules/server#optionalrestargs)\<`FuncRef`> |

#### Returns

`void`

***

### daily

▸ **daily**\<`FuncRef`>(`cronIdentifier`, `schedule`, `functionReference`, `...args`): `void`

Schedule a mutation or action to run on a daily basis.

```js theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
crons.daily(
  "Reset high scores",
  {
    hourUTC: 17, // (9:30am Pacific/10:30am Daylight Savings Pacific)
    minuteUTC: 30,
  },
  api.scores.reset
)
```

#### Type parameters

| Name | Type |
| :- | :- |
| `FuncRef` | extends `SchedulableFunctionReferenceCompat` |

#### Parameters

| Name | Type | Description |
| :- | :- | :- |
| `cronIdentifier` | `string` | A unique name for this scheduled job. |
| `schedule` | `Daily` | What time (UTC) each day to run this function. |
| `functionReference` | `FuncRef` | A [FunctionReference](/api/modules/server#functionreference) or [FunctionReference\_future](/api/modules/server#functionreference_future) for the function to schedule. |
| `...args` | [`OptionalRestArgs`](/api/modules/server#optionalrestargs)\<`FuncRef`> | The arguments to the function. |

#### Returns

`void`

***

### weekly

▸ **weekly**\<`FuncRef`>(`cronIdentifier`, `schedule`, `functionReference`, `...args`): `void`

Schedule a mutation or action to run on a weekly basis.

```js theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
crons.weekly(
  "Weekly re-engagement email",
  {
    dayOfWeek: "Tuesday",
    hourUTC: 17, // (9:30am Pacific/10:30am Daylight Savings Pacific)
    minuteUTC: 30,
  },
  api.emails.send
)
```

#### Type parameters

| Name | Type |
| :- | :- |
| `FuncRef` | extends `SchedulableFunctionReferenceCompat` |

#### Parameters

| Name | Type | Description |
| :- | :- | :- |
| `cronIdentifier` | `string` | A unique name for this scheduled job. |
| `schedule` | `Weekly` | What day and time (UTC) each week to run this function. |
| `functionReference` | `FuncRef` | A [FunctionReference](/api/modules/server#functionreference) or [FunctionReference\_future](/api/modules/server#functionreference_future) for the function to schedule. |
| `...args` | [`OptionalRestArgs`](/api/modules/server#optionalrestargs)\<`FuncRef`> | - |

#### Returns

`void`

***

### monthly

▸ **monthly**\<`FuncRef`>(`cronIdentifier`, `schedule`, `functionReference`, `...args`): `void`

Schedule a mutation or action to run on a monthly basis.

Note that some months have fewer days than others, so e.g. a function
scheduled to run on the 30th will not run in February.

```js theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
crons.monthly(
  "Bill customers at ",
  {
    hourUTC: 17, // (9:30am Pacific/10:30am Daylight Savings Pacific)
    minuteUTC: 30,
    day: 1,
  },
  api.billing.billCustomers
)
```

#### Type parameters

| Name | Type |
| :- | :- |
| `FuncRef` | extends `SchedulableFunctionReferenceCompat` |

#### Parameters

| Name | Type | Description |
| :- | :- | :- |
| `cronIdentifier` | `string` | A unique name for this scheduled job. |
| `schedule` | `Monthly` | What day and time (UTC) each month to run this function. |
| `functionReference` | `FuncRef` | A [FunctionReference](/api/modules/server#functionreference) or [FunctionReference\_future](/api/modules/server#functionreference_future) for the function to schedule. |
| `...args` | [`OptionalRestArgs`](/api/modules/server#optionalrestargs)\<`FuncRef`> | The arguments to the function. |

#### Returns

`void`

***

### cron

▸ **cron**\<`FuncRef`>(`cronIdentifier`, `cron`, `functionReference`, `...args`): `void`

Schedule a mutation or action to run on a recurring basis.

Like the unix command `cron`, Sunday is 0, Monday is 1, etc.

```
 ┌─ minute (0 - 59)
 │ ┌─ hour (0 - 23)
 │ │ ┌─ day of the month (1 - 31)
 │ │ │ ┌─ month (1 - 12)
 │ │ │ │ ┌─ day of the week (0 - 6) (Sunday to Saturday)
"* * * * *"
```

#### Type parameters

| Name | Type |
| :- | :- |
| `FuncRef` | extends `SchedulableFunctionReferenceCompat` |

#### Parameters

| Name | Type | Description |
| :- | :- | :- |
| `cronIdentifier` | `string` | A unique name for this scheduled job. |
| `cron` | `string` | Cron string like `"15 7 * * *"` (Every day at 7:15 UTC) |
| `functionReference` | `FuncRef` | A [FunctionReference](/api/modules/server#functionreference) or [FunctionReference\_future](/api/modules/server#functionreference_future) for the function to schedule. |
| `...args` | [`OptionalRestArgs`](/api/modules/server#optionalrestargs)\<`FuncRef`> | The arguments to the function. |

#### Returns

`void`
