---
title: "Cron Triggers"
---

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

# Cron Triggers

A Cron Trigger runs a Worker's `scheduled` handler on a schedule. workerd
keeps each Worker's schedule in a Durable Object whose alarm calls the
handler, so a cluster runs each occurrence on one instance. Read the
[Cloudflare Cron Triggers documentation](https://developers.cloudflare.com/workers/configuration/cron-triggers/)
for the API.

## Example

The Cron Trigger example logs the scheduled time once
a minute.

```js title="index.js"
export default {
  async fetch(request, env) {
    return new Response("The cron runs once a minute.\n");
  },
  async scheduled(controller, env, ctx) {
    console.log("cron", controller.scheduledTime);
  },
};
```

```jsonc title="wrangler.jsonc"
{
  "name": "cron",
  "main": "index.js",
  "compatibility_date": "2026-01-01",
  "no_bundle": true,
  "triggers": { "crons": ["* * * * *"] }
}
```

Cron Triggers are experimental, so they need `--experimental`:

```sh
npx workerd serve --experimental ./cron/wrangler.jsonc
```

At the start of each minute, workerd prints a line such as
`cron 1795555260000`, the scheduled time in milliseconds.

## Schedules

A project declares its schedules in a `triggers.crons` array. workerd reads
the Cloudflare cron dialect, in UTC:

- five fields
- weekdays
  [numbered 1 to 7 from Sunday](https://developers.cloudflare.com/workers/configuration/cron-triggers/),
  so `1-5` means Sunday to Thursday
- `L`, `W`, and `#` in the day fields

When both day fields are restricted, a day matches when one of them
matches. An expression that workerd cannot parse stops startup.

## Differences from Cloudflare

- workerd refuses a descending range such as `SAT-SUN`, a list that
  contains `*` such as `1,*`, and an expression that never matches.
- A handler that throws runs again 2 seconds later. The delay doubles after
  each failure, for up to six retries. A retry keeps the `scheduledTime` of
  its occurrence. If the next occurrence comes before a pending retry, it
  replaces the retry. `controller.noRetry()` stops the retries.
- The runs of one Worker never overlap. workerd skips an occurrence if a
  handler still runs at its time. A run that takes longer than 10 minutes
  counts as a failure.
- After downtime, workerd runs the first missed occurrence once and
  skips the others.

See also [Cloudflare compatibility](https://workerd.dev/docs/cloudflare-compat/#services).

Source: https://workerd.dev/docs/services/cron-triggers/index.mdx
