Cron Triggers, Scheduled Handlers, Expressions and Local Test
How edge scheduled() handlers run on cron expressions, Wrangler triggers config, Workflow schedules, and Local Explorer local testing.
This page summarises Cloudflare documentation on Cron Triggers: mapping a cron expression to a Worker’s scheduled() handler for periodic jobs, configuring schedules in Wrangler or the dashboard, and testing invocations locally without waiting for the clock.
Cron Triggers: what runs on a schedule
Section titled “Cron Triggers: what runs on a schedule”Cron Triggers let you map a cron expression to a Worker that implements a scheduled() handler, so the Worker runs on a fixed timetable instead of only on HTTP requests.
Cron Triggers allow users to map a cron expression to a Worker using a scheduled() handler that enables Workers to be executed on a schedule.
— Cloudflare, Cron Triggers
They suit maintenance work, polling third-party APIs, rebuild hooks, and similar background tasks. Scheduled Workers run on underutilised capacity in Cloudflare’s network. All Cron Trigger times use UTC.
Cron Triggers target production deployments. Worker Previews do not get separate scheduled invocations; to exercise scheduled logic on a Preview URL, call shared logic from both scheduled() and a test-only route.
scheduled() handler: how to implement periodic jobs
Section titled “scheduled() handler: how to implement periodic jobs”When a Cron Trigger fires, the runtime invokes your Worker’s scheduled() handler (not fetch()).
JavaScript (ES modules):
export default { async scheduled(controller, env, ctx) { console.log("cron processed"); },};Python Workers use a WorkerEntrypoint with scheduled(self, controller, env, ctx) — all four parameters are required. See Cron triggers in Python Workers and the Scheduled Handler reference.
Useful ScheduledController fields:
| Property | Meaning |
|---|---|
controller.cron |
Exact cron string from configuration that triggered this run |
controller.scheduledTime |
Scheduled instant in ms since epoch (UTC) |
controller.type |
Always "scheduled" |
When several crons share one Worker, branch on controller.cron; the string must match the config character-for-character (spacing included). See Multiple Cron Triggers and Handle multiple cron triggers.
ctx.waitUntil(promise) registers extra async work whose failure can surface in Past Cron Events; the runtime still waits for the promise returned by scheduled() itself (up to the Worker duration limit). Details are in Scheduled Handler — Methods.
Wrangler triggers.crons: how to set the schedule
Section titled “Wrangler triggers.crons: how to set the schedule”After you add scheduled() to your code, define crons in project configuration. If the Worker is managed with Wrangler, manage Cron Triggers only through the Wrangler config (not only the dashboard), per Cron Triggers — Via the Wrangler configuration file.
{ "triggers": { "crons": ["*/3 * * * *", "0 15 1 * *", "59 23 LW * *"] }}With the Cloudflare CLI, you can use triggers.scheduled({ schedule: "0 * * * *" }) in cloudflare.config.ts — see Via cloudflare.config.ts.
| Action | Config behaviour |
|---|---|
| Disable all crons | "crons": [] — commenting out crons does not disable triggers |
| Deploy with Wrangler | Deploy replaces cron list with what is in triggers; empty array removes all |
Omit triggers / crons |
Existing deployed crons stay in place |
| Per environment | Put triggers under env.<name> in Wrangler |
The per-Worker cap of three Cron Triggers was removed in 2023; account-level maximums still apply — see Workers limits via Cron Triggers — Limits.
You can also add or remove crons in the dashboard under Workers & Pages → your Worker → Settings → Triggers → Cron Triggers, as described in Via the dashboard.
Supported cron expressions: UTC syntax and examples
Section titled “Supported cron expressions: UTC syntax and examples”Cloudflare uses five fields plus Quartz-like extensions (L, W, LW, #, ranges, steps). Weekdays are 1 = Sunday … 7 = Saturday (not Unix 0–6).
| Field | Values | Special |
|---|---|---|
| Minute | 0–59 | * , - / |
| Hour | 0–23 | * , - / |
| Day of month | 1–31 | * , - / L W |
| Month | 1–12 or JAN… |
* , - / |
| Weekday | 1–7 or MON… |
* , - / L # |
Common patterns from Examples:
*/30 * * * *— every 30 minutes10 7 * * mon-fri— 07:10 UTC on weekdays59 23 LW * *— 23:59 UTC on the last weekday of the month
Full field rules: Supported cron expressions.
Workflow schedules vs Worker Cron Triggers
Section titled “Workflow schedules vs Worker Cron Triggers”For durable multi-step jobs (retries, long runs), you can put schedules on the Workflow binding in Wrangler instead of a thin scheduled() Worker that only calls env.MY_WORKFLOW.create().
You can now attach cron schedules directly to a Workflow binding in wrangler.jsonc. Each scheduled run creates a new Workflow instance automatically, so you do not need to define a separate Worker with a scheduled handler just to trigger your Workflow on an interval.
— Cloudflare, Schedule Workflow instances directly from your Workflow binding
Inside the Workflow, event.schedule carries the cron and scheduledTime when the run was schedule-driven (Trigger Workflows — Schedule a Workflow directly). A D1 backup example uses "schedules": ["0 0 * * *"] on the binding.
Keep a Worker Cron Trigger + scheduled() when you need custom code before deciding whether to start a Workflow (learning path note).
Test Cron Triggers locally: Local Explorer and HTTP routes
Section titled “Test Cron Triggers locally: Local Explorer and HTTP routes”Local dev does not fire crons automatically. You send one-off invocations while cf dev, wrangler dev, or the Cloudflare Vite plugin is running.
Cron testing in Local Explorer needs Wrangler 4.139.0+ or Cloudflare Vite plugin 1.60.0+ (Test Cron Triggers locally). Open /cdn-cgi/local/explorer on your dev server URL (for example port 8787 or Vite’s 5173).
Local Explorer can now send one-off Cron Trigger invocations to a Worker’s scheduled() handler during local development. This removes the need to construct request URLs when testing handler behavior.
— Cloudflare, Test Cron Triggers with Local Explorer
In the UI you can:
- Invoke configured crons (at least one cron required in the active environment for that path)
- Build ad hoc expressions (stored in the browser only — they do not change Wrangler or deployed crons)
- Set scheduled time presets and inspect outcome and
noRetry()status
With Observability enabled on the dev session, logs and traces appear for that Worker (Local Explorer — Test Cron Triggers).
HTTP shortcut without the browser UI
Section titled “HTTP shortcut without the browser UI”With --test-scheduled, Wrangler exposes /cdn-cgi/local/scheduled:
npx wrangler dev --test-scheduledcurl "http://localhost:8787/cdn-cgi/local/scheduled?format=json"curl "http://localhost:8787/cdn-cgi/local/scheduled?cron=*+*+*+*+*&time=1745856238000"noRetry is true when the handler called controller.noRetry(). For a named Worker in a multi-worker session, POST to the Local Explorer API (Use the Local Explorer API):
curl -X POST \ "http://localhost:8787/cdn-cgi/local/explorer/api/local/scheduled?worker=my-worker" \ -H "Content-Type: application/json" \ --data '{"cron":"0 * * * *","scheduled_time":1745856238000}'The OpenAPI spec lives at GET /cdn-cgi/local/explorer/api (Local Explorer API). When an AI agent session is detected, the dev server prints a hint to that API for traces, bindings, and scheduled tests (Debug with AI agents).
Production monitoring and common mistakes
Section titled “Production monitoring and common mistakes”Past Cron Events in the dashboard (Settings → Trigger Events → View events) keeps the 100 most recent scheduled invocations; Workers Logs retains longer history. Optional hour-bucket rebuild patterns appear in Deploy Hooks and Pages API scheduled builds.
Typical pitfalls:
- Expecting crons to run locally on their own — they do not; use Local Explorer or
/cdn-cgi/local/scheduled. - Using
switch (event.cron)with a string that does not exactly match Wranglercrons. - Commenting out
cronsinstead of settingcrons = []when you intend to disable triggers (Wrangler configuration — Triggers). - Testing scheduled behaviour only on Previews without a callable test route (Previews — Cron Triggers).
- Forgetting UTC when aligning crons with business hours.
Account-level Green Compute can restrict cron execution to renewable-powered PoPs (Green Compute).
Experimental wrangler triggers deploy can apply cron changes with versions upload (workers triggers deploy).
How to check this on your site
Section titled “How to check this on your site”-
Confirm the deployed Worker exports
scheduled()and thattriggers.crons(or dashboard Cron Triggers) lists the expressions you expect, using Wrangler configuration — Triggers as reference. -
After deploy, wait for propagation (up to ~15 minutes), then open Workers & Pages → your Worker → Settings → Trigger Events → View events and confirm recent invocations per View past events.
-
Locally, start
cf devorwrangler dev --test-scheduled, open Local Explorer at/cdn-cgi/local/explorer, run Cron Triggers → Configured Crons → Trigger, and verify outcome andnoRetrymatch your handler. -
Optionally call
curl "http://localhost:<port>/cdn-cgi/local/scheduled?format=json&cron=<your-expression>"and compare JSONoutcomewith dashboard Past Cron Events after a production tick. -
You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page does not match your project or the linked Cloudflare docs, email yimasynthetic@gmail.com with the page URL and the exact sentence you think is wrong or unclear.