Define a cron job
Use the@worker.cron decorator with a cron expression:
Cron expression format
UpNext supports both 5-field and 6-field cron expressions:| Field | 5-field | 6-field | Values |
|---|---|---|---|
| Seconds | - | 1st | 0-59 |
| Minutes | 1st | 2nd | 0-59 |
| Hours | 2nd | 3rd | 0-23 |
| Day of month | 3rd | 4th | 1-31 |
| Month | 4th | 5th | 1-12 |
| Day of week | 5th | 6th | 0-6 (Sun-Sat) |
Cron options
| Parameter | Type | Default | Description |
|---|---|---|---|
schedule | str | required | Cron expression |
name | str | None | Custom display name |
timeout | float | 1800 | Maximum execution time in seconds |
missed_run_policy | MissedRunPolicy | LATEST_ONLY | How to handle missed runs |
max_catch_up_seconds | float | None | Max time window for catching up missed runs |
Missed run policies
If a worker was down and missed scheduled runs, themissed_run_policy controls what happens when it comes back:
LATEST_ONLY(default) — Run only the most recent missed execution, skip the rest.RUN_ALL— Run every missed execution in order, bounded bymax_catch_up_seconds.
Using context in cron jobs
Cron jobs have full access to the execution context, just like tasks:Next: Events
Pub/sub handlers that trigger when an event is published.