Schedule recurring runs
Publish workflow jobs on a cron schedule with an explicit time zone.
Publish a job on a schedule
Section titled “Publish a job on a schedule”Create a schedule with createCronSchedule() and give it a cron expression and time zone. runSchedules() publishes a queue job at each matching time until you abort its signal; a worker runs the job separately.
Run the script
Section titled “Run the script”At 02:00 Paris time, Monday to Friday, the scheduler publishes a job for the audit handler with a runId such as audit-2026-09-30. Ctrl+C aborts the signal and runSchedules() resolves.
API reference: CronOptions.
Run the published jobs
Section titled “Run the published jobs”A worker opens the same queue and registers audit with defineWorkflowJob(), which runs one checkpointed workflow per runId: see Job queues and workers. The Nightly maintenance recipe shows the scheduler and the worker together.
Write the cron expression
Section titled “Write the cron expression”Use five fields in minute, hour, day-of-month, month and day-of-week order. For example, 0 2 * * 1-5 schedules 02:00 on weekdays; @daily schedules midnight. Set timeZone explicitly when the local time matters. The createCronSchedule contract lists names, ranges, steps, macros and the rule for combining both day fields.
Name each run after its local date
Section titled “Name each run after its local date”slot.toISOString().slice(0, 10) gives the UTC date. At 01:00 in Paris, that is still the previous day.
Use slot.toLocaleDateString("en-CA", { timeZone }) with the schedule’s time zone, as in the first snippet, to get the local date as YYYY-MM-DD.
Daylight saving time
Section titled “Daylight saving time”Slots are wall-clock times in the schedule’s time zone.
- Skipped time: A time that does not exist on the spring-forward day does not fire that day.
- Repeated time: A time that occurs twice on the fall-back day fires once, at its first occurrence.
Run several schedulers
Section titled “Run several schedulers”Each slot publishes the job schedule:<name>:<slot ISO time>. A restarted scheduler, or several replicas sharing one queue, publish the same job ID, and the queue keeps a single job.
runId and input must depend only on the slot. The queue rejects a second publication of the same ID with a different request.
Two schedules can return the same runId for one day: the second job then reuses the same checkpointed run if its input is the same (a different input fails with an incompatible checkpoint), like the 07:00 resume in Nightly maintenance.
Catch up after a restart
Section titled “Catch up after a restart”A slot is published only if at most maxLateMs has passed since it (60 000 ms by default). After a restart or a suspended process, only the latest missed slot within that window is published; older ones are skipped.
Raise maxLateMs to catch up a slot missed during a longer outage, for example maxLateMs: 6 * 60 * 60_000 for six hours.
Handle publication failures
Section titled “Handle publication failures”Without onError, the first failed publication stops every schedule and rejects runSchedules(). With it, you receive the error with the schedule name and slot, and scheduling continues with the next slot.
A failed slot is not published again. Errors thrown by onError are ignored.
Compute slots without publishing
Section titled “Compute slots without publishing”next(after) returns the first slot strictly after a date, previous(at) the latest slot at or before it. Neither publishes anything.
This prints 2026-03-30T00:30:00.000Z: 02:30 does not exist in Paris on 29 March 2026.
createCronSchedule() throws on an invalid field, an unknown time zone or an expression with no occurrence, such as 0 0 30 2 *.
Schedule from CI instead
Section titled “Schedule from CI instead”Without a long-running process, a scheduled CI job, such as a GitHub Actions schedule workflow, can start the workflow directly with a checkpoint. See Run in CI.
File workspaces
Section titled “File workspaces”A file recipe uses the same schedule-to-queue contract: a timer only publishes its deterministic job, and the worker allocates the workspace. See file workspaces and recipe services.
Limits
Section titled “Limits”- The finest resolution is one minute.
- After downtime, only the latest missed slot within
maxLateMsis published. - A schedule
nameis unique and uses letters, digits,.,_and-(128 characters at most). ArunIdhas at most 256 characters.
API: createCronSchedule · runSchedules · TriggerSchedule · CronSchedule · defineWorkflowJob.
Wall-clock deduplication also applies to wildcard expressions such as 0 * * * *: the repeated local hour at the autumn DST transition fires once, leaving a two-hour real-time gap. Use UTC for a constant hourly cadence. Time zones are interpreted by Intl, including its accepted aliases; prefer explicit IANA regions rather than abbreviations such as EST. maxLateMs must be positive. A slow queue publication counts as lateness too: only the latest eligible slot is published after it finishes, and intermediate slots are intentionally coalesced. onError reports publication failures, not these coalesced slots.

