Cron Triggers
Background
Cron Triggers allow users to map a cron expression to a Worker script using a ScheduledEvent listener that enables Workers to be executed on a schedule. Cron Triggers are ideal for running periodic jobs for maintenance or calling third-party APIs to collect up-to-date data. Workers scheduled by Cron Triggers will run on underutilized machines to make the best use of Cloudflare’s capacity and route traffic efficiently.
Add a Cron Trigger
You can add Cron Triggers to Workers with the Cloudflare API, or in the dashboard in Workers > Manage Workers > select your Worker > Triggers. Refer to Limits to track the maximum number of Cron Triggers per Worker. If a Worker is managed with Wrangler, Cron Triggers should be exclusively managed through the wrangler.toml
file.
Supported cron expressions
Cloudflare supports cron expressions with five fields, along with most Quartz scheduler-like cron syntax extensions:
Field | Values | Characters |
---|---|---|
Minute | 0-59 | * , - / |
Hours | 0-23 | * , - / |
Days of Month | 1-31 | * , - / L W |
Months | 1-12, case-insensitive 3-letter abbreviations (“JAN”, “aug”, etc.) | * , - / |
Weekdays | 1-7, case-insensitive 3-letter abbreviations (“MON”, “fri”, etc.) | * , - / L # |
Examples
Some common time intervals that may be useful for setting up your Cron Trigger:
* * * * *
- Every minute
*/30 * * * *
- Every 30 minutes
45 * * * *
- On the 45th minute of every hour
0 17 * * sun
or0 17 * * 1
- 5PM on Sunday
10 7 * * mon-fri
or10 7 * * 2-6
- 7:10AM on weekdays
0 15 1 * *
- 3PM on first day of the month
0 18 * * 6L
or0 18 * * friL
- 6PM on the last Friday of the month
23 59 LW * *
- 11:59PM on the last weekday of the month
Viewing past events
Users can review the execution history of their Cron Triggers in Past Events under Triggers or through Cloudflare’s GraphQL Analytics API.
It can take up to 30 minutes before events are displayed in Past Events when creating a new Worker or changing a Worker’s name.
Refer to Metrics and Analytics for more information.