# Cron and Quartz expressions

cronpad accepts standard Unix cron (five fields, optionally a sixth for seconds, plus `@daily`-style descriptors) and Quartz cron (six or seven fields with the special characters `?`, `L`, `W` and `#`). Both are evaluated in the job's timezone.

## Standard cron

```
┌──────────── second (optional, 0–59)
│ ┌────────── minute (0–59)
│ │ ┌──────── hour (0–23)
│ │ │ ┌────── day of month (1–31)
│ │ │ │ ┌──── month (1–12 or JAN–DEC)
│ │ │ │ │ ┌── day of week (0–6 or SUN–SAT; 0 = Sunday)
│ │ │ │ │ │
* * * * * *
```

| Syntax | Meaning | Example |
|---|---|---|
| `*` | Every value | `* * * * *` every minute |
| `,` | List | `0 9,18 * * *` at 09:00 and 18:00 |
| `-` | Range | `0 9 * * 1-5` 09:00 Monday–Friday |
| `/` | Step | `*/15 * * * *` every 15 minutes |
| Names | Months and weekdays | `0 0 * JAN,JUL MON` |

### Examples

| Expression | Fires |
|---|---|
| `*/5 * * * *` | Every 5 minutes |
| `0 * * * *` | At the start of every hour |
| `30 2 * * *` | 02:30 every day |
| `0 9 * * 1-5` | 09:00 on weekdays |
| `0 0 1 * *` | Midnight on the 1st of every month |
| `*/30 * * * * *` | Every 30 seconds (six fields: seconds first) |

### Descriptors

| Descriptor | Equivalent |
|---|---|
| `@yearly`, `@annually` | `0 0 1 1 *` |
| `@monthly` | `0 0 1 * *` |
| `@weekly` | `0 0 * * 0` |
| `@daily`, `@midnight` | `0 0 * * *` |
| `@hourly` | `0 * * * *` |
| `@every 90m` | Every 90 minutes, measured as a fixed duration (not wall-clock aligned) |

:::caution
When both day-of-month and day-of-week are restricted, classic cron fires when **either** matches: `0 9 13 * FRI` fires on every 13th *and* every Friday. For "Friday the 13th", use natural language or RRULE.
:::

## Quartz cron

Quartz expressions always include seconds and may include a year:

```
seconds minutes hours day-of-month month day-of-week [year]
```

Differences from standard cron:

- Day of week is `1–7` with **1 = Sunday** (names `SUN–SAT` also work and are clearer).
- Exactly one of day-of-month and day-of-week must be `?` ("no specific value"), unless both fields are `*`.
- Extra special characters:

| Character | Field | Meaning | Example |
|---|---|---|---|
| `?` | day-of-month, day-of-week | No specific value | `0 0 9 ? * MON` |
| `L` | day-of-month | Last day of the month | `0 0 18 L * ?` |
| `L-n` | day-of-month | n days before the last day | `0 0 9 L-3 * ?` |
| `W` | day-of-month | Nearest weekday to the given day | `0 0 9 15W * ?` |
| `LW` | day-of-month | Last weekday of the month | `0 0 17 LW * ?` |
| `nL` | day-of-week | Last given weekday of the month | `0 0 17 ? * 6L` (last Friday) |
| `n#k` | day-of-week | k-th given weekday of the month | `0 0 9 ? * 6#3` (third Friday) |

### Examples

| Expression | Fires |
|---|---|
| `0 0 18 L * ?` | 18:00 on the last day of every month |
| `0 0 9 ? * 3#2` | 09:00 on the second Tuesday |
| `0 0 9 15W * ?` | 09:00 on the weekday nearest the 15th |
| `0 0 17 LW * ?` | 17:00 on the last weekday of the month |
| `0 30 10 ? * MON-FRI 2027` | 10:30 on weekdays, during 2027 only |

cronpad searches at most five years ahead for the next match. An expression that never matches within five years (for example `0 0 0 30 FEB ?`) is rejected when you save it.

## How cronpad tells them apart

A six-field expression without `?`, `L`, `W` or `#` is standard cron with seconds. Seven fields, or any of those characters, means Quartz. Set `"kind": "cron"` or `"kind": "quartz"` to be explicit.