Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive Cloudflare platform skill covering Workers, D1, R2, KV, AI, Durable Objects, and security.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/cron-triggers/README.md
1# Cloudflare Cron Triggers23Schedule Workers execution using cron expressions. Runs on Cloudflare's global network during underutilized periods.45## Key Features67- **UTC-only execution** - All schedules run on UTC time8- **5-field cron syntax** - Quartz scheduler extensions (L, W, #)9- **Global propagation** - 15min deployment delay10- **At-least-once delivery** - Rare duplicate executions possible11- **Workflow integration** - Trigger long-running multi-step tasks12- **Green Compute** - Optional carbon-aware scheduling during low-carbon periods1314## Cron Syntax1516```17┌─────────── minute (0-59)18│ ┌───────── hour (0-23)19│ │ ┌─────── day of month (1-31)20│ │ │ ┌───── month (1-12, JAN-DEC)21│ │ │ │ ┌─── day of week (1-7, SUN-SAT, 1=Sunday)22* * * * *23```2425**Special chars:** `*` (any), `,` (list), `-` (range), `/` (step), `L` (last), `W` (weekday), `#` (nth)2627## Common Schedules2829```bash30*/5 * * * * # Every 5 minutes310 * * * * # Hourly320 2 * * * # Daily 2am UTC (off-peak)330 9 * * MON-FRI # Weekdays 9am UTC340 0 1 * * # Monthly 1st midnight UTC350 9 L * * # Last day of month 9am UTC360 10 * * MON#2 # 2nd Monday 10am UTC37*/10 9-17 * * MON-FRI # Every 10min, 9am-5pm weekdays38```3940## Quick Start4142**wrangler.jsonc:**43```jsonc44{45"name": "my-cron-worker",46"triggers": {47"crons": ["*/5 * * * *", "0 2 * * *"]48}49}50```5152**Handler:**53```typescript54export default {55async scheduled(56controller: ScheduledController,57env: Env,58ctx: ExecutionContext,59): Promise<void> {60console.log("Cron:", controller.cron);61console.log("Time:", new Date(controller.scheduledTime));6263ctx.waitUntil(asyncTask(env)); // Non-blocking64},65};66```6768**Test locally:**69```bash70npx wrangler dev71curl "http://localhost:8787/__scheduled?cron=*/5+*+*+*+*"72```7374## Limits7576- **Free:** 3 triggers/worker, 10ms CPU77- **Paid:** Unlimited triggers, 30s CPU (<1hr interval) / 15min CPU (≥1hr interval)78- **Propagation:** 15min global deployment79- **Timezone:** UTC only8081## Reading Order8283**New to cron triggers?** Start here:841. This README - Overview and quick start852. [configuration.md](./configuration.md) - Set up your first cron trigger863. [api.md](./api.md) - Understand the handler API874. [patterns.md](./patterns.md) - Common use cases and examples8889**Troubleshooting?** Jump to [gotchas.md](./gotchas.md)9091## In This Reference92- [configuration.md](./configuration.md) - wrangler config, env-specific schedules, Green Compute93- [api.md](./api.md) - ScheduledController, noRetry(), waitUntil, testing patterns94- [patterns.md](./patterns.md) - Use cases, monitoring, queue integration, Durable Objects95- [gotchas.md](./gotchas.md) - Timezone issues, idempotency, security, testing9697## See Also98- [workflows](../workflows/) - Alternative for long-running scheduled tasks99- [workers](../workers/) - Worker runtime documentation100