[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79A2J4M52TJWMKQ3VAX2J9E":3,"skill-same:01M79A2J4M52TJWMKQ3VAX2J9E":108},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":42,"commitSha":43,"skillDirectory":44,"forksCount":14,"repositoryHtmlUrl":45,"repositoryHomepageUrl":6,"ownerHtmlUrl":46,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":47,"install":48,"resources":61},"01M79A2J4M52TJWMKQ3VAX2J9E","cloudflare-cron-triggers",null,"Cloudflare Cron Triggers for scheduled Workers execution. Use for periodic tasks, scheduled jobs, or encountering handler not found, invalid cron expression, timezone errors.","Elogic360\u002Fsoftware-factory","Elogic360","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F156535519?v=4","01M74NH3F0RB13PWB7JZDE2V80","elogic360","01M74NH3FPC65082MDZVMFHDM3",0,"MIT","https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fintegrations\u002Fclaude-skills-secondsky\u002Fplugins\u002Fcloudflare-cron-triggers\u002Fskills\u002Fcloudflare-cron-triggers\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: cloudflare-cron-triggers\ndescription: \"Cloudflare Cron Triggers for scheduled Workers execution. Use for periodic tasks, scheduled jobs, or encountering handler not found, invalid cron expression, timezone errors.\"\n\nmetadata:\n  keywords:\n    - cloudflare cron\n    - cron triggers\n    - scheduled workers\n    - scheduled handler\n    - periodic tasks\n    - background jobs\n    - scheduled tasks\n    - cron expression\n    - wrangler crons\n    - scheduled event\n    - green compute\n    - workflow triggers\n    - maintenance tasks\n    - scheduled() handler\n    - ScheduledController\n    - UTC timezone\n\nlicense: MIT\n---\n# Cloudflare Cron Triggers\n\n**Status**: Production Ready ✅\n**Last Updated**: 2025-11-25\n**Dependencies**: cloudflare-worker-base (for Worker setup)\n**Latest Versions**: wrangler@4.50.0, @cloudflare\u002Fworkers-types@4.20251125.0\n\n---\n\n## Quick Start (5 Minutes)\n\n### 1. Add Scheduled Handler to Your Worker\n\n**src\u002Findex.ts:**\n\n```typescript\nexport default {\n  async scheduled(\n    controller: ScheduledController,\n    env: Env,\n    ctx: ExecutionContext\n  ): Promise\u003Cvoid> {\n    console.log('Cron job executed at:', new Date(controller.scheduledTime));\n    console.log('Triggered by cron:', controller.cron);\n\n    \u002F\u002F Your scheduled task logic here\n    await doPeriodicTask(env);\n  },\n};\n```\n\n**Why this matters:**\n- Handler must be named exactly `scheduled` (not `scheduledHandler` or `onScheduled`)\n- Must be exported in default export object\n- Must use ES modules format (not Service Worker format)\n\n### 2. Configure Cron Trigger in Wrangler\n\n**wrangler.jsonc:**\n\n```jsonc\n{\n  \"name\": \"my-scheduled-worker\",\n  \"main\": \"src\u002Findex.ts\",\n  \"compatibility_date\": \"2025-10-23\",\n  \"triggers\": {\n    \"crons\": [\n      \"0 * * * *\"  \u002F\u002F Every hour at minute 0\n    ]\n  }\n}\n```\n\n**CRITICAL:**\n- Cron expressions use 5 fields: `minute hour day-of-month month day-of-week`\n- All times are **UTC only** (no timezone conversion)\n- Changes take **up to 15 minutes** to propagate globally\n\n### 3. Test Locally\n\n```bash\n# Enable scheduled testing\nbunx wrangler dev --test-scheduled\n\n# In another terminal, trigger the scheduled handler\ncurl \"http:\u002F\u002Flocalhost:8787\u002F__scheduled?cron=0+*+*+*+*\"\n\n# View output in wrangler dev terminal\n```\n\n**Testing tips:**\n- `\u002F__scheduled` endpoint is only available with `--test-scheduled` flag\n- Can pass any cron expression in query parameter\n- Python Workers use `\u002Fcdn-cgi\u002Fhandler\u002Fscheduled` instead\n\n### 4. Deploy\n\n```bash\nnpm run deploy\n# or\nbunx wrangler deploy\n```\n\n**After deployment:**\n- Changes may take up to 15 minutes to propagate\n- Check dashboard: Workers & Pages > [Your Worker] > **Cron Triggers**\n- View past executions in **Logs** tab\n\n---\n\n## When to Load References\n\n**Load immediately when user mentions**:\n\n- `cron-expressions-reference.md` → \"cron syntax\", \"schedule format\", \"expression\", \"minute hour day\", \"every X minutes\"\n- `common-patterns.md` → \"examples\", \"use cases\", \"patterns\", \"real-world\", \"database cleanup\", \"report generation\", \"how to\"\n- `integration-patterns.md` → \"implement\", \"Hono\", \"multiple triggers\", \"bindings\", \"workflows\", \"error handling\"\n- `wrangler-config.md` → \"configuration\", \"wrangler.jsonc\", \"multiple crons\", \"environment-specific\", \"dev staging production\"\n- `testing-guide.md` → \"test\", \"local development\", \"__scheduled\", \"unit test\", \"curl\", \"debugging\"\n\n**Load proactively when**:\n- Building new scheduled task → Load `integration-patterns.md`\n- Configuring wrangler.jsonc → Load `wrangler-config.md`\n- Debugging cron expression → Load `cron-expressions-reference.md`\n- Testing locally → Load `testing-guide.md`\n- Looking for examples → Load `common-patterns.md`\n\n---\n\n## Cron Expression Syntax\n\n### Five-Field Format\n\n```\n* * * * *\n│ │ │ │ │\n│ │ │ │ └─── Day of Week (0-6, Sunday=0)\n│ │ │ └───── Month (1-12)\n│ │ └─────── Day of Month (1-31)\n│ └───────── Hour (0-23)\n└─────────── Minute (0-59)\n```\n\n### Special Characters\n\n| Character | Meaning | Example |\n|-----------|---------|---------|\n| `*` | Every | `* * * * *` = every minute |\n| `,` | List | `0,30 * * * *` = every hour at :00 and :30 |\n| `-` | Range | `0 9-17 * * *` = every hour from 9am-5pm |\n| `\u002F` | Step | `*\u002F15 * * * *` = every 15 minutes |\n\n### Common Patterns\n\n```bash\n# Every minute\n* * * * *\n\n# Every 5 minutes\n*\u002F5 * * * *\n\n# Every 15 minutes\n*\u002F15 * * * *\n\n# Every hour at minute 0\n0 * * * *\n\n# Every hour at minute 30\n30 * * * *\n\n# Every 6 hours\n0 *\u002F6 * * *\n\n# Every day at midnight (00:00 UTC)\n0 0 * * *\n\n# Every day at noon (12:00 UTC)\n0 12 * * *\n\n# Every day at 3:30am UTC\n30 3 * * *\n\n# Every Monday at 9am UTC\n0 9 * * 1\n\n# Every weekday at 9am UTC\n0 9 * * 1-5\n\n# Every Sunday at midnight UTC\n0 0 * * 0\n\n# First day of every month at midnight UTC\n0 0 1 * *\n\n# Twice a day (6am and 6pm UTC)\n0 6,18 * * *\n\n# Every 30 minutes during business hours (9am-5pm UTC, weekdays)\n*\u002F30 9-17 * * 1-5\n```\n\n**CRITICAL: UTC Timezone Only**\n- All cron triggers execute on **UTC time**\n- No timezone conversion available\n- Convert your local time to UTC manually\n- Example: 9am PST = 5pm UTC (next day during DST)\n\n---\n\n## ScheduledController Interface\n\n```typescript\ninterface ScheduledController {\n  readonly cron: string;           \u002F\u002F The cron expression that triggered this execution\n  readonly type: string;           \u002F\u002F Always \"scheduled\"\n  readonly scheduledTime: number;  \u002F\u002F Unix timestamp (ms) when scheduled\n}\n```\n\n### Properties\n\n#### `controller.cron` (string)\n\nThe cron expression that triggered this execution.\n\n```typescript\nexport default {\n  async scheduled(controller: ScheduledController, env: Env): Promise\u003Cvoid> {\n    console.log(`Triggered by: ${controller.cron}`);\n    \u002F\u002F Output: \"Triggered by: 0 * * * *\"\n  },\n};\n```\n\n**Use case:** Differentiate between multiple cron schedules (see Multiple Cron Triggers pattern).\n\n#### `controller.type` (string)\n\nAlways returns `\"scheduled\"` for cron-triggered executions.\n\n```typescript\nif (controller.type === 'scheduled') {\n  \u002F\u002F This is a cron-triggered execution\n}\n```\n\n#### `controller.scheduledTime` (number)\n\nUnix timestamp (milliseconds since epoch) when this execution was scheduled to run.\n\n```typescript\nexport default {\n  async scheduled(controller: ScheduledController): Promise\u003Cvoid> {\n    const scheduledDate = new Date(controller.scheduledTime);\n    console.log(`Scheduled for: ${scheduledDate.toISOString()}`);\n    \u002F\u002F Output: \"Scheduled for: 2025-10-23T15:00:00.000Z\"\n  },\n};\n```\n\n**Note:** This is the **scheduled** time, not the actual execution time. Due to system load, actual execution may be slightly delayed (usually \u003C1 second).\n\n---\n\n## Execution Context\n\n```typescript\nexport default {\n  async scheduled(\n    controller: ScheduledController,\n    env: Env,\n    ctx: ExecutionContext  \u002F\u002F ← Execution context\n  ): Promise\u003Cvoid> {\n    \u002F\u002F Use ctx.waitUntil() for async operations that should complete\n    ctx.waitUntil(logToAnalytics(env));\n  },\n};\n```\n\n### `ctx.waitUntil(promise: Promise\u003Cany>)`\n\nExtends the execution context to wait for async operations to complete after the handler returns.\n\n**Use cases:**\n- Logging to external services\n- Analytics tracking\n- Cleanup operations\n- Non-critical background tasks\n\n```typescript\nexport default {\n  async scheduled(controller: ScheduledController, env: Env, ctx: ExecutionContext): Promise\u003Cvoid> {\n    \u002F\u002F Critical task - must complete before handler exits\n    await processData(env);\n\n    \u002F\u002F Non-critical tasks - can complete in background\n    ctx.waitUntil(sendMetrics(env));\n    ctx.waitUntil(cleanupOldData(env));\n    ctx.waitUntil(notifySlack({ message: 'Cron completed' }));\n  },\n};\n```\n\n**Important:** First `waitUntil()` that fails will be reported as the status in dashboard logs.\n\n---\n\n## Integration Patterns\n\n**6 production-ready cron patterns**:\n\n1. **Standalone Worker with Cron** - Single scheduled function for background tasks (database cleanup, report generation)\n2. **Hono + Cron Combination** - HTTP endpoints + scheduled tasks in one Worker, sharing bindings and reducing costs\n3. **Multiple Cron Triggers** - Different schedules for different tasks using `controller.cron` to route execution\n4. **Accessing Bindings** - Use D1, KV, R2, AI, Vectorize, Queues, Workflows, Durable Objects in scheduled functions\n5. **Integrating with Workflows** - Trigger complex, long-running multi-step workflows on schedule\n6. **Error Handling Best Practices** - Comprehensive error handling with retry logic, alerting (Slack\u002Femail), failure logging, and monitoring\n\n**Load `references\u002Fintegration-patterns.md` for complete implementations with code examples, configuration details, and best practices.**\n\n---\n\n## Wrangler Configuration\n\nAdd cron triggers to `wrangler.jsonc` in the `triggers.crons` array. Each trigger requires a `cron` expression. Supports multiple crons (Free: 3 max, Paid: higher limits) and environment-specific configurations for dev\u002Fstaging\u002Fproduction deployments.\n\n**Load `references\u002Fwrangler-config.md` for complete configuration examples including multiple triggers, environment-specific schedules, timezone handling, and removal procedures.**\n\n---\n\n## Testing & Development\n\nTest scheduled functions locally using the `\u002F__scheduled` endpoint by running `bunx wrangler dev --test-scheduled`, then triggering handlers with `curl \"http:\u002F\u002Flocalhost:8787\u002F__scheduled?cron=0+*+*+*+*\"` (use `+` instead of spaces in cron expressions).\n\n**Load `references\u002Ftesting-guide.md` for complete testing strategies, local development setup, unit testing examples, integration testing patterns, and production monitoring techniques.**\n\n---\n\n## Green Compute\n\nRun cron triggers only in data centers powered by renewable energy.\n\n### Enable Green Compute\n\n**Via Dashboard:**\n\n1. Go to [Workers & Pages](https:\u002F\u002Fdash.cloudflare.com\u002F?to=\u002F:account\u002Fworkers-and-pages)\n2. In **Account details** section, find **Compute Setting**\n3. Click **Change**\n4. Select **Green Compute**\n5. Click **Confirm**\n\n**Applies to:**\n- All cron triggers in your account\n- Reduces carbon footprint\n- No additional cost\n- May introduce slight delays in some regions\n\n**How it works:**\n- Cloudflare routes cron executions to green-powered data centers\n- Uses renewable energy: wind, solar, hydroelectric\n- Verified through Power Purchase Agreements (PPAs) and Renewable Energy Credits (RECs)\n\n---\n\n## Known Issues Prevention\n\nThis skill prevents **6** documented issues:\n\n### Issue #1: Cron Changes Not Propagating\n\n**Error:** Cron triggers updated in wrangler.jsonc but not executing\n\n**Source:** [Cloudflare Docs - Cron Triggers](https:\u002F\u002Fdevelopers.cloudflare.com\u002Fworkers\u002Fconfiguration\u002Fcron-triggers\u002F)\n\n**Why It Happens:**\n- Changes to cron triggers take up to **15 minutes** to propagate globally\n- Cloudflare network needs time to update edge nodes\n- No instant propagation like regular deploys\n\n**Prevention:**\n- Wait 15 minutes after deploy before expecting execution\n- Check dashboard: Workers & Pages > [Worker] > Cron Triggers\n- Use `wrangler triggers deploy` for trigger-only changes\n\n```bash\n# If you only changed triggers (not code), use:\nbunx wrangler triggers deploy\n\n# Wait 15 minutes, then verify in dashboard\n```\n\n---\n\n### Issue #2: Handler Does Not Export\n\n**Error:** `Handler does not export a 'scheduled' method`\n\n**Source:** Common deployment error\n\n**Why It Happens:**\n- Handler not named exactly `scheduled`\n- Handler not exported in default export object\n- Using Service Worker format instead of ES modules\n\n**Prevention:**\n\n```typescript\n\u002F\u002F ❌ Wrong: Incorrect handler name\nexport default {\n  async scheduledHandler(controller, env, ctx) { }\n};\n\n\u002F\u002F ❌ Wrong: Not in default export\nexport async function scheduled(controller, env, ctx) { }\n\n\u002F\u002F ✅ Correct: Named 'scheduled' in default export\nexport default {\n  async scheduled(controller, env, ctx) { }\n};\n```\n\n---\n\n### Issue #3: UTC Timezone Confusion\n\n**Error:** Cron runs at wrong time\n\n**Source:** User expectation vs. reality\n\n**Why It Happens:**\n- All cron triggers run on **UTC time only**\n- No timezone conversion available\n- Users expect local timezone\n\n**Prevention:**\n\nConvert your local time to UTC manually:\n\n```typescript\n\u002F\u002F Want to run at 9am PST (UTC-8)?\n\u002F\u002F 9am PST = 5pm UTC (17:00)\n{\n  \"triggers\": {\n    \"crons\": [\"0 17 * * *\"]  \u002F\u002F 9am PST = 5pm UTC\n  }\n}\n\n\u002F\u002F Want to run at 6pm EST (UTC-5)?\n\u002F\u002F 6pm EST = 11pm UTC (23:00)\n{\n  \"triggers\": {\n    \"crons\": [\"0 23 * * *\"]  \u002F\u002F 6pm EST = 11pm UTC\n  }\n}\n\n\u002F\u002F Remember: DST changes affect conversion!\n\u002F\u002F PST is UTC-8, PDT is UTC-7\n```\n\n**Tools:**\n- [Time Zone Converter](https:\u002F\u002Fwww.timeanddate.com\u002Fworldclock\u002Fconverter.html)\n- [Cron Expression Generator](https:\u002F\u002Fcrontab.guru\u002F)\n\n---\n\n### Issue #4: Invalid Cron Expression\n\n**Error:** Cron doesn't execute, no error shown\n\n**Source:** Silent validation failure\n\n**Why It Happens:**\n- Invalid cron syntax silently fails\n- Validation happens at deploy, but may not be obvious\n- Common mistakes: wrong field order, invalid ranges\n\n**Prevention:**\n\n```bash\n# ❌ Wrong: Too many fields (6 fields instead of 5)\n\"crons\": [\"0 0 * * * *\"]  # Has seconds field - not supported\n\n# ❌ Wrong: Invalid minute range\n\"crons\": [\"65 * * * *\"]  # Minute must be 0-59\n\n# ❌ Wrong: Invalid day of week\n\"crons\": [\"0 0 * * 7\"]  # Day of week is 0-6 (use 0 for Sunday)\n\n# ✅ Correct: 5 fields, valid ranges\n\"crons\": [\"0 0 * * 0\"]  # Sunday at midnight UTC\n```\n\n**Validation:**\n- Use [Crontab Guru](https:\u002F\u002Fcrontab.guru\u002F) to validate expressions\n- Check wrangler deploy output for errors\n- Test locally with `--test-scheduled`\n\n---\n\n### Issue #5: Missing ES Modules Format\n\n**Error:** `Worker must use ES modules format`\n\n**Source:** Legacy Service Worker format\n\n**Why It Happens:**\n- Scheduled handler requires ES modules format\n- Old Service Worker format not supported\n- Mixed format in codebase\n\n**Prevention:**\n\n```typescript\n\u002F\u002F ❌ Wrong: Service Worker format\naddEventListener('scheduled', (event) => {\n  event.waitUntil(handleScheduled(event));\n});\n\n\u002F\u002F ✅ Correct: ES modules format\nexport default {\n  async scheduled(controller, env, ctx) {\n    await handleScheduled(controller, env, ctx);\n  },\n};\n```\n\n---\n\n### Issue #6: CPU Time Limits Exceeded\n\n**Error:** `CPU time limit exceeded`\n\n**Source:** Long-running scheduled tasks\n\n**Why It Happens:**\n- Default CPU limit: 30 seconds\n- Long-running tasks exceed limit\n- No automatic timeout extension\n\n**Prevention:**\n\n**Option 1: Increase CPU limit in wrangler.jsonc**\n\n```jsonc\n{\n  \"limits\": {\n    \"cpu_ms\": 300000  \u002F\u002F 5 minutes (max for Standard plan)\n  }\n}\n```\n\n**Option 2: Use Workflows for long-running tasks**\n\n```typescript\n\u002F\u002F Instead of long task in cron:\nexport default {\n  async scheduled(controller, env, ctx) {\n    \u002F\u002F Trigger Workflow that can run for hours\n    await env.MY_WORKFLOW.create({\n      params: { task: 'long-running-job' },\n    });\n  },\n};\n```\n\n**Option 3: Break into smaller chunks**\n\n```typescript\nexport default {\n  async scheduled(controller, env, ctx) {\n    \u002F\u002F Process in batches\n    const batch = await getNextBatch(env.DB);\n\n    for (const item of batch) {\n      await processItem(item);\n    }\n\n    \u002F\u002F If more work, send to Queue for next batch\n    const hasMore = await hasMoreWork(env.DB);\n    if (hasMore) {\n      await env.MY_QUEUE.send({ type: 'continue-processing' });\n    }\n  },\n};\n```\n\n---\n\n## Always Do ✅\n\n1. **Use exact handler name** - Must be `scheduled`, not `scheduledHandler` or variants\n2. **Use ES modules format** - Export in default object, not addEventListener\n3. **Convert to UTC** - All cron times are UTC, convert from local timezone\n4. **Wait 15 minutes** - Cron changes take up to 15 min to propagate\n5. **Test locally first** - Use `wrangler dev --test-scheduled`\n6. **Validate cron syntax** - Use [Crontab Guru](https:\u002F\u002Fcrontab.guru\u002F)\n7. **Handle errors gracefully** - Log, alert, and optionally re-throw\n8. **Use ctx.waitUntil()** - For non-critical async operations\n9. **Consider Workflows** - For tasks that need >30 seconds CPU time\n10. **Monitor executions** - Check dashboard logs regularly\n\n---\n\n## Never Do ❌\n\n1. **Never assume local timezone** - All crons run on UTC\n2. **Never use 6-field cron expressions** - Cloudflare uses 5-field format (no seconds)\n3. **Never rely on instant propagation** - Changes take up to 15 minutes\n4. **Never use Service Worker format** - Must use ES modules format\n5. **Never forget error handling** - Uncaught errors fail silently\n6. **Never run CPU-intensive tasks without limit increase** - Default 30s limit\n7. **Never use day-of-week 7** - Use 0 for Sunday (0-6 range only)\n8. **Never deploy without testing** - Always test with `--test-scheduled` first\n9. **Never ignore execution logs** - Dashboard shows past failures\n10. **Never hardcode schedules for testing** - Use environment-specific configs\n\n---\n\n## Common Use Cases\n\n**Load `references\u002Fcommon-patterns.md` for 10 real-world cron patterns including database cleanup, API data collection, daily reports generation, cache warming, monitoring & health checks, data synchronization, backup automation, sitemap generation, webhook processing, and scheduled notifications.**\n\n---\n\n## TypeScript Types\n\n```typescript\n\u002F\u002F Scheduled event controller\ninterface ScheduledController {\n  readonly cron: string;\n  readonly type: string;\n  readonly scheduledTime: number;\n}\n\n\u002F\u002F Execution context\ninterface ExecutionContext {\n  waitUntil(promise: Promise\u003Cany>): void;\n  passThroughOnException(): void;\n}\n\n\u002F\u002F Scheduled handler\nexport default {\n  async scheduled(\n    controller: ScheduledController,\n    env: Env,\n    ctx: ExecutionContext\n  ): Promise\u003Cvoid>;\n}\n```\n\n---\n\n## Limits & Pricing\n\n### Limits\n\n| Feature | Free Plan | Paid Plan |\n|---------|-----------|-----------|\n| **Cron triggers per Worker** | 3 | Higher (check docs) |\n| **CPU time per execution** | 10 ms (avg) | 30 seconds (default), 5 min (max) |\n| **Wall clock time** | 30 seconds | 15 minutes |\n| **Memory** | 128 MB | 128 MB |\n\n### Pricing\n\nCron triggers use **Standard Workers pricing**:\n\n- **Workers Paid Plan**: $5\u002Fmonth required\n- **Requests**: $0.30 per million requests (after 10M free)\n- **CPU Time**: $0.02 per million CPU-ms (after 30M free)\n\n**Cron execution = 1 request**\n\n**Example:**\n- Cron runs every hour (24 times\u002Fday)\n- 30 days × 24 executions = 720 executions\u002Fmonth\n- Average 50ms CPU time per execution\n\n**Cost:**\n- Requests: 720 (well under 10M free)\n- CPU time: 720 × 50ms = 36,000ms (under 30M free)\n- **Total: $5\u002Fmonth (just subscription)**\n\n**High frequency example:**\n- Cron runs every minute (1440 times\u002Fday)\n- 30 days × 1440 = 43,200 executions\u002Fmonth\n- Still under free tier limits\n- **Total: $5\u002Fmonth**\n\n---\n\n## Troubleshooting\n\n### Issue: Cron not executing\n\n**Possible causes:**\n1. Changes not propagated yet (wait 15 minutes)\n2. Invalid cron expression\n3. Handler not exported correctly\n4. Worker not deployed\n\n**Solution:**\n\n```bash\n# Re-deploy\nbunx wrangler deploy\n\n# Wait 15 minutes\n\n# Check dashboard\n# Workers & Pages > [Worker] > Cron Triggers\n\n# Check logs\n# Workers & Pages > [Worker] > Logs > Real-time Logs\n```\n\n---\n\n### Issue: Handler executes but fails\n\n**Possible causes:**\n1. Uncaught error in handler\n2. CPU time limit exceeded\n3. Missing environment bindings\n4. Network timeout\n\n**Solution:**\n\n```typescript\nexport default {\n  async scheduled(controller, env, ctx) {\n    try {\n      await yourTask(env);\n    } catch (error) {\n      \u002F\u002F Log detailed error\n      console.error('Handler failed:', {\n        error: error.message,\n        stack: error.stack,\n        cron: controller.cron,\n        time: new Date(controller.scheduledTime),\n      });\n\n      \u002F\u002F Send alert\n      ctx.waitUntil(sendAlert(error));\n\n      \u002F\u002F Re-throw to mark as failed\n      throw error;\n    }\n  },\n};\n```\n\nCheck logs in dashboard for error details.\n\n---\n\n### Issue: Wrong execution time\n\n**Cause:** UTC vs. local timezone confusion\n\n**Solution:**\n\nConvert your desired local time to UTC:\n\n```typescript\n\u002F\u002F Want 9am PST (UTC-8)?\n\u002F\u002F 9am PST = 5pm UTC (17:00)\n\n{\n  \"triggers\": {\n    \"crons\": [\"0 17 * * *\"]\n  }\n}\n```\n\n**Tools:**\n- [World Clock Converter](https:\u002F\u002Fwww.timeanddate.com\u002Fworldclock\u002Fconverter.html)\n- Remember DST changes (PST vs PDT)\n\n---\n\n### Issue: Local testing not working\n\n**Possible causes:**\n1. Missing `--test-scheduled` flag\n2. Wrong endpoint (should be `\u002F__scheduled`)\n3. Python Worker (use `\u002Fcdn-cgi\u002Fhandler\u002Fscheduled`)\n\n**Solution:**\n\n```bash\n# Correct: Start with flag\nbunx wrangler dev --test-scheduled\n\n# In another terminal\ncurl \"http:\u002F\u002Flocalhost:8787\u002F__scheduled?cron=0+*+*+*+*\"\n```\n\n---\n\n## Production Checklist\n\nBefore deploying cron triggers to production:\n\n- [ ] Cron expression validated on [Crontab Guru](https:\u002F\u002Fcrontab.guru\u002F)\n- [ ] Handler named exactly `scheduled` in default export\n- [ ] ES modules format used (not Service Worker)\n- [ ] Local timezone converted to UTC\n- [ ] Error handling implemented with logging\n- [ ] Alerts configured for failures\n- [ ] CPU limits increased if needed (`limits.cpu_ms`)\n- [ ] Environment bindings tested\n- [ ] Tested locally with `--test-scheduled`\n- [ ] Deployment tested in staging environment\n- [ ] Waited 15 minutes after deploy for propagation\n- [ ] Verified execution in dashboard logs\n- [ ] Monitoring and alerting configured\n- [ ] Documentation updated with schedule details\n\n---\n\n## Related Documentation\n\n- **Cloudflare Cron Triggers**: https:\u002F\u002Fdevelopers.cloudflare.com\u002Fworkers\u002Fconfiguration\u002Fcron-triggers\u002F\n- **Scheduled Handler API**: https:\u002F\u002Fdevelopers.cloudflare.com\u002Fworkers\u002Fruntime-apis\u002Fhandlers\u002Fscheduled\u002F\n- **Cron Trigger Examples**: https:\u002F\u002Fdevelopers.cloudflare.com\u002Fworkers\u002Fexamples\u002Fcron-trigger\u002F\n- **Multiple Cron Triggers**: https:\u002F\u002Fdevelopers.cloudflare.com\u002Fworkers\u002Fexamples\u002Fmultiple-cron-triggers\u002F\n- **Wrangler Triggers Command**: https:\u002F\u002Fdevelopers.cloudflare.com\u002Fworkers\u002Fwrangler\u002Fcommands\u002F#triggers\n- **Workers Pricing**: https:\u002F\u002Fdevelopers.cloudflare.com\u002Fworkers\u002Fplatform\u002Fpricing\u002F\n- **Workflows Integration**: https:\u002F\u002Fdevelopers.cloudflare.com\u002Fworkflows\u002F\n- **Crontab Guru** (validator): https:\u002F\u002Fcrontab.guru\u002F\n- **Time Zone Converter**: https:\u002F\u002Fwww.timeanddate.com\u002Fworldclock\u002Fconverter.html\n\n---\n\n**Last Updated**: 2025-10-23\n**Version**: 1.0.0\n**Maintainer**: Claude Skills Maintainers | maintainers@example.com\n","# Cloudflare Cron Triggers\n\n**Status**: Production Ready ✅\n**Last Updated**: 2025-11-25\n**Dependencies**: cloudflare-worker-base (for Worker setup)\n**Latest Versions**: wrangler@4.50.0, @cloudflare\u002Fworkers-types@4.20251125.0\n\n---\n\n## Quick Start (5 Minutes)\n\n### 1. Add Scheduled Handler to Your Worker\n\n**src\u002Findex.ts:**\n\n```typescript\nexport default {\n  async scheduled(\n    controller: ScheduledController,\n    env: Env,\n    ctx: ExecutionContext\n  ): Promise\u003Cvoid> {\n    console.log('Cron job executed at:', new Date(controller.scheduledTime));\n    console.log('Triggered by cron:', controller.cron);\n\n    \u002F\u002F Your scheduled task logic here\n    await doPeriodicTask(env);\n  },\n};\n```\n\n**Why this matters:**\n- Handler must be named exactly `scheduled` (not `scheduledHandler` or `onScheduled`)\n- Must be exported in default export object\n- Must use ES modules format (not Service Worker format)\n\n### 2. Configure Cron Trigger in Wrangler\n\n**wrangler.jsonc:**\n\n```jsonc\n{\n  \"name\": \"my-scheduled-worker\",\n  \"main\": \"src\u002Findex.ts\",\n  \"compatibility_date\": \"2025-10-23\",\n  \"triggers\": {\n    \"crons\": [\n      \"0 * * * *\"  \u002F\u002F Every hour at minute 0\n    ]\n  }\n}\n```\n\n**CRITICAL:**\n- Cron expressions use 5 fields: `minute hour day-of-month month day-of-week`\n- All times are **UTC only** (no timezone conversion)\n- Changes take **up to 15 minutes** to propagate globally\n\n### 3. Test Locally\n\n```bash\n# Enable scheduled testing\nbunx wrangler dev --test-scheduled\n\n# In another terminal, trigger the scheduled handler\ncurl \"http:\u002F\u002Flocalhost:8787\u002F__scheduled?cron=0+*+*+*+*\"\n\n# View output in wrangler dev terminal\n```\n\n**Testing tips:**\n- `\u002F__scheduled` endpoint is only available with `--test-scheduled` flag\n- Can pass any cron expression in query parameter\n- Python Workers use `\u002Fcdn-cgi\u002Fhandler\u002Fscheduled` instead\n\n### 4. Deploy\n\n```bash\nnpm run deploy\n# or\nbunx wrangler deploy\n```\n\n**After deployment:**\n- Changes may take up to 15 minutes to propagate\n- Check dashboard: Workers & Pages > [Your Worker] > **Cron Triggers**\n- View past executions in **Logs** tab\n\n---\n\n## When to Load References\n\n**Load immediately when user mentions**:\n\n- `cron-expressions-reference.md` → \"cron syntax\", \"schedule format\", \"expression\", \"minute hour day\", \"every X minutes\"\n- `common-patterns.md` → \"examples\", \"use cases\", \"patterns\", \"real-world\", \"database cleanup\", \"report generation\", \"how to\"\n- `integration-patterns.md` → \"implement\", \"Hono\", \"multiple triggers\", \"bindings\", \"workflows\", \"error handling\"\n- `wrangler-config.md` → \"configuration\", \"wrangler.jsonc\", \"multiple crons\", \"environment-specific\", \"dev staging production\"\n- `testing-guide.md` → \"test\", \"local development\", \"__scheduled\", \"unit test\", \"curl\", \"debugging\"\n\n**Load proactively when**:\n- Building new scheduled task → Load `integration-patterns.md`\n- Configuring wrangler.jsonc → Load `wrangler-config.md`\n- Debugging cron expression → Load `cron-expressions-reference.md`\n- Testing locally → Load `testing-guide.md`\n- Looking for examples → Load `common-patterns.md`\n\n---\n\n## Cron Expression Syntax\n\n### Five-Field Format\n\n```\n* * * * *\n│ │ │ │ │\n│ │ │ │ └─── Day of Week (0-6, Sunday=0)\n│ │ │ └───── Month (1-12)\n│ │ └─────── Day of Month (1-31)\n│ └───────── Hour (0-23)\n└─────────── Minute (0-59)\n```\n\n### Special Characters\n\n| Character | Meaning | Example |\n|-----------|---------|---------|\n| `*` | Every | `* * * * *` = every minute |\n| `,` | List | `0,30 * * * *` = every hour at :00 and :30 |\n| `-` | Range | `0 9-17 * * *` = every hour from 9am-5pm |\n| `\u002F` | Step | `*\u002F15 * * * *` = every 15 minutes |\n\n### Common Patterns\n\n```bash\n# Every minute\n* * * * *\n\n# Every 5 minutes\n*\u002F5 * * * *\n\n# Every 15 minutes\n*\u002F15 * * * *\n\n# Every hour at minute 0\n0 * * * *\n\n# Every hour at minute 30\n30 * * * *\n\n# Every 6 hours\n0 *\u002F6 * * *\n\n# Every day at midnight (00:00 UTC)\n0 0 * * *\n\n# Every day at noon (12:00 UTC)\n0 12 * * *\n\n# Every day at 3:30am UTC\n30 3 * * *\n\n# Every Monday at 9am UTC\n0 9 * * 1\n\n# Every weekday at 9am UTC\n0 9 * * 1-5\n\n# Every Sunday at midnight UTC\n0 0 * * 0\n\n# First day of every month at midnight UTC\n0 0 1 * *\n\n# Twice a day (6am and 6pm UTC)\n0 6,18 * * *\n\n# Every 30 minutes during business hours (9am-5pm UTC, weekdays)\n*\u002F30 9-17 * * 1-5\n```\n\n**CRITICAL: UTC Timezone Only**\n- All cron triggers execute on **UTC time**\n- No timezone conversion available\n- Convert your local time to UTC manually\n- Example: 9am PST = 5pm UTC (next day during DST)\n\n---\n\n## ScheduledController Interface\n\n```typescript\ninterface ScheduledController {\n  readonly cron: string;           \u002F\u002F The cron expression that triggered this execution\n  readonly type: string;           \u002F\u002F Always \"scheduled\"\n  readonly scheduledTime: number;  \u002F\u002F Unix timestamp (ms) when scheduled\n}\n```\n\n### Properties\n\n#### `controller.cron` (string)\n\nThe cron expression that triggered this execution.\n\n```typescript\nexport default {\n  async scheduled(controller: ScheduledController, env: Env): Promise\u003Cvoid> {\n    console.log(`Triggered by: ${controller.cron}`);\n    \u002F\u002F Output: \"Triggered by: 0 * * * *\"\n  },\n};\n```\n\n**Use case:** Differentiate between multiple cron schedules (see Multiple Cron Triggers pattern).\n\n#### `controller.type` (string)\n\nAlways returns `\"scheduled\"` for cron-triggered executions.\n\n```typescript\nif (controller.type === 'scheduled') {\n  \u002F\u002F This is a cron-triggered execution\n}\n```\n\n#### `controller.scheduledTime` (number)\n\nUnix timestamp (milliseconds since epoch) when this execution was scheduled to run.\n\n```typescript\nexport default {\n  async scheduled(controller: ScheduledController): Promise\u003Cvoid> {\n    const scheduledDate = new Date(controller.scheduledTime);\n    console.log(`Scheduled for: ${scheduledDate.toISOString()}`);\n    \u002F\u002F Output: \"Scheduled for: 2025-10-23T15:00:00.000Z\"\n  },\n};\n```\n\n**Note:** This is the **scheduled** time, not the actual execution time. Due to system load, actual execution may be slightly delayed (usually \u003C1 second).\n\n---\n\n## Execution Context\n\n```typescript\nexport default {\n  async scheduled(\n    controller: ScheduledController,\n    env: Env,\n    ctx: ExecutionContext  \u002F\u002F ← Execution context\n  ): Promise\u003Cvoid> {\n    \u002F\u002F Use ctx.waitUntil() for async operations that should complete\n    ctx.waitUntil(logToAnalytics(env));\n  },\n};\n```\n\n### `ctx.waitUntil(promise: Promise\u003Cany>)`\n\nExtends the execution context to wait for async operations to complete after the handler returns.\n\n**Use cases:**\n- Logging to external services\n- Analytics tracking\n- Cleanup operations\n- Non-critical background tasks\n\n```typescript\nexport default {\n  async scheduled(controller: ScheduledController, env: Env, ctx: ExecutionContext): Promise\u003Cvoid> {\n    \u002F\u002F Critical task - must complete before handler exits\n    await processData(env);\n\n    \u002F\u002F Non-critical tasks - can complete in background\n    ctx.waitUntil(sendMetrics(env));\n    ctx.waitUntil(cleanupOldData(env));\n    ctx.waitUntil(notifySlack({ message: 'Cron completed' }));\n  },\n};\n```\n\n**Important:** First `waitUntil()` that fails will be reported as the status in dashboard logs.\n\n---\n\n## Integration Patterns\n\n**6 production-ready cron patterns**:\n\n1. **Standalone Worker with Cron** - Single scheduled function for background tasks (database cleanup, report generation)\n2. **Hono + Cron Combination** - HTTP endpoints + scheduled tasks in one Worker, sharing bindings and reducing costs\n3. **Multiple Cron Triggers** - Different schedules for different tasks using `controller.cron` to route execution\n4. **Accessing Bindings** - Use D1, KV, R2, AI, Vectorize, Queues, Workflows, Durable Objects in scheduled functions\n5. **Integrating with Workflows** - Trigger complex, long-running multi-step workflows on schedule\n6. **Error Handling Best Practices** - Comprehensive error handling with retry logic, alerting (Slack\u002Femail), failure logging, and monitoring\n\n**Load `references\u002Fintegration-patterns.md` for complete implementations with code examples, configuration details, and best practices.**\n\n---\n\n## Wrangler Configuration\n\nAdd cron triggers to `wrangler.jsonc` in the `triggers.crons` array. Each trigger requires a `cron` expression. Supports multiple crons (Free: 3 max, Paid: higher limits) and environment-specific configurations for dev\u002Fstaging\u002Fproduction deployments.\n\n**Load `references\u002Fwrangler-config.md` for complete configuration examples including multiple triggers, environment-specific schedules, timezone handling, and removal procedures.**\n\n---\n\n## Testing & Development\n\nTest scheduled functions locally using the `\u002F__scheduled` endpoint by running `bunx wrangler dev --test-scheduled`, then triggering handlers with `curl \"http:\u002F\u002Flocalhost:8787\u002F__scheduled?cron=0+*+*+*+*\"` (use `+` instead of spaces in cron expressions).\n\n**Load `references\u002Ftesting-guide.md` for complete testing strategies, local development setup, unit testing examples, integration testing patterns, and production monitoring techniques.**\n\n---\n\n## Green Compute\n\nRun cron triggers only in data centers powered by renewable energy.\n\n### Enable Green Compute\n\n**Via Dashboard:**\n\n1. Go to [Workers & Pages](https:\u002F\u002Fdash.cloudflare.com\u002F?to=\u002F:account\u002Fworkers-and-pages)\n2. In **Account details** section, find **Compute Setting**\n3. Click **Change**\n4. Select **Green Compute**\n5. Click **Confirm**\n\n**Applies to:**\n- All cron triggers in your account\n- Reduces carbon footprint\n- No additional cost\n- May introduce slight delays in some regions\n\n**How it works:**\n- Cloudflare routes cron executions to green-powered data centers\n- Uses renewable energy: wind, solar, hydroelectric\n- Verified through Power Purchase Agreements (PPAs) and Renewable Energy Credits (RECs)\n\n---\n\n## Known Issues Prevention\n\nThis skill prevents **6** documented issues:\n\n### Issue #1: Cron Changes Not Propagating\n\n**Error:** Cron triggers updated in wrangler.jsonc but not executing\n\n**Source:** [Cloudflare Docs - Cron Triggers](https:\u002F\u002Fdevelopers.cloudflare.com\u002Fworkers\u002Fconfiguration\u002Fcron-triggers\u002F)\n\n**Why It Happens:**\n- Changes to cron triggers take up to **15 minutes** to propagate globally\n- Cloudflare network needs time to update edge nodes\n- No instant propagation like regular deploys\n\n**Prevention:**\n- Wait 15 minutes after deploy before expecting execution\n- Check dashboard: Workers & Pages > [Worker] > Cron Triggers\n- Use `wrangler triggers deploy` for trigger-only changes\n\n```bash\n# If you only changed triggers (not code), use:\nbunx wrangler triggers deploy\n\n# Wait 15 minutes, then verify in dashboard\n```\n\n---\n\n### Issue #2: Handler Does Not Export\n\n**Error:** `Handler does not export a 'scheduled' method`\n\n**Source:** Common deployment error\n\n**Why It Happens:**\n- Handler not named exactly `scheduled`\n- Handler not exported in default export object\n- Using Service Worker format instead of ES modules\n\n**Prevention:**\n\n```typescript\n\u002F\u002F ❌ Wrong: Incorrect handler name\nexport default {\n  async scheduledHandler(controller, env, ctx) { }\n};\n\n\u002F\u002F ❌ Wrong: Not in default export\nexport async function scheduled(controller, env, ctx) { }\n\n\u002F\u002F ✅ Correct: Named 'scheduled' in default export\nexport default {\n  async scheduled(controller, env, ctx) { }\n};\n```\n\n---\n\n### Issue #3: UTC Timezone Confusion\n\n**Error:** Cron runs at wrong time\n\n**Source:** User expectation vs. reality\n\n**Why It Happens:**\n- All cron triggers run on **UTC time only**\n- No timezone conversion available\n- Users expect local timezone\n\n**Prevention:**\n\nConvert your local time to UTC manually:\n\n```typescript\n\u002F\u002F Want to run at 9am PST (UTC-8)?\n\u002F\u002F 9am PST = 5pm UTC (17:00)\n{\n  \"triggers\": {\n    \"crons\": [\"0 17 * * *\"]  \u002F\u002F 9am PST = 5pm UTC\n  }\n}\n\n\u002F\u002F Want to run at 6pm EST (UTC-5)?\n\u002F\u002F 6pm EST = 11pm UTC (23:00)\n{\n  \"triggers\": {\n    \"crons\": [\"0 23 * * *\"]  \u002F\u002F 6pm EST = 11pm UTC\n  }\n}\n\n\u002F\u002F Remember: DST changes affect conversion!\n\u002F\u002F PST is UTC-8, PDT is UTC-7\n```\n\n**Tools:**\n- [Time Zone Converter](https:\u002F\u002Fwww.timeanddate.com\u002Fworldclock\u002Fconverter.html)\n- [Cron Expression Generator](https:\u002F\u002Fcrontab.guru\u002F)\n\n---\n\n### Issue #4: Invalid Cron Expression\n\n**Error:** Cron doesn't execute, no error shown\n\n**Source:** Silent validation failure\n\n**Why It Happens:**\n- Invalid cron syntax silently fails\n- Validation happens at deploy, but may not be obvious\n- Common mistakes: wrong field order, invalid ranges\n\n**Prevention:**\n\n```bash\n# ❌ Wrong: Too many fields (6 fields instead of 5)\n\"crons\": [\"0 0 * * * *\"]  # Has seconds field - not supported\n\n# ❌ Wrong: Invalid minute range\n\"crons\": [\"65 * * * *\"]  # Minute must be 0-59\n\n# ❌ Wrong: Invalid day of week\n\"crons\": [\"0 0 * * 7\"]  # Day of week is 0-6 (use 0 for Sunday)\n\n# ✅ Correct: 5 fields, valid ranges\n\"crons\": [\"0 0 * * 0\"]  # Sunday at midnight UTC\n```\n\n**Validation:**\n- Use [Crontab Guru](https:\u002F\u002Fcrontab.guru\u002F) to validate expressions\n- Check wrangler deploy output for errors\n- Test locally with `--test-scheduled`\n\n---\n\n### Issue #5: Missing ES Modules Format\n\n**Error:** `Worker must use ES modules format`\n\n**Source:** Legacy Service Worker format\n\n**Why It Happens:**\n- Scheduled handler requires ES modules format\n- Old Service Worker format not supported\n- Mixed format in codebase\n\n**Prevention:**\n\n```typescript\n\u002F\u002F ❌ Wrong: Service Worker format\naddEventListener('scheduled', (event) => {\n  event.waitUntil(handleScheduled(event));\n});\n\n\u002F\u002F ✅ Correct: ES modules format\nexport default {\n  async scheduled(controller, env, ctx) {\n    await handleScheduled(controller, env, ctx);\n  },\n};\n```\n\n---\n\n### Issue #6: CPU Time Limits Exceeded\n\n**Error:** `CPU time limit exceeded`\n\n**Source:** Long-running scheduled tasks\n\n**Why It Happens:**\n- Default CPU limit: 30 seconds\n- Long-running tasks exceed limit\n- No automatic timeout extension\n\n**Prevention:**\n\n**Option 1: Increase CPU limit in wrangler.jsonc**\n\n```jsonc\n{\n  \"limits\": {\n    \"cpu_ms\": 300000  \u002F\u002F 5 minutes (max for Standard plan)\n  }\n}\n```\n\n**Option 2: Use Workflows for long-running tasks**\n\n```typescript\n\u002F\u002F Instead of long task in cron:\nexport default {\n  async scheduled(controller, env, ctx) {\n    \u002F\u002F Trigger Workflow that can run for hours\n    await env.MY_WORKFLOW.create({\n      params: { task: 'long-running-job' },\n    });\n  },\n};\n```\n\n**Option 3: Break into smaller chunks**\n\n```typescript\nexport default {\n  async scheduled(controller, env, ctx) {\n    \u002F\u002F Process in batches\n    const batch = await getNextBatch(env.DB);\n\n    for (const item of batch) {\n      await processItem(item);\n    }\n\n    \u002F\u002F If more work, send to Queue for next batch\n    const hasMore = await hasMoreWork(env.DB);\n    if (hasMore) {\n      await env.MY_QUEUE.send({ type: 'continue-processing' });\n    }\n  },\n};\n```\n\n---\n\n## Always Do ✅\n\n1. **Use exact handler name** - Must be `scheduled`, not `scheduledHandler` or variants\n2. **Use ES modules format** - Export in default object, not addEventListener\n3. **Convert to UTC** - All cron times are UTC, convert from local timezone\n4. **Wait 15 minutes** - Cron changes take up to 15 min to propagate\n5. **Test locally first** - Use `wrangler dev --test-scheduled`\n6. **Validate cron syntax** - Use [Crontab Guru](https:\u002F\u002Fcrontab.guru\u002F)\n7. **Handle errors gracefully** - Log, alert, and optionally re-throw\n8. **Use ctx.waitUntil()** - For non-critical async operations\n9. **Consider Workflows** - For tasks that need >30 seconds CPU time\n10. **Monitor executions** - Check dashboard logs regularly\n\n---\n\n## Never Do ❌\n\n1. **Never assume local timezone** - All crons run on UTC\n2. **Never use 6-field cron expressions** - Cloudflare uses 5-field format (no seconds)\n3. **Never rely on instant propagation** - Changes take up to 15 minutes\n4. **Never use Service Worker format** - Must use ES modules format\n5. **Never forget error handling** - Uncaught errors fail silently\n6. **Never run CPU-intensive tasks without limit increase** - Default 30s limit\n7. **Never use day-of-week 7** - Use 0 for Sunday (0-6 range only)\n8. **Never deploy without testing** - Always test with `--test-scheduled` first\n9. **Never ignore execution logs** - Dashboard shows past failures\n10. **Never hardcode schedules for testing** - Use environment-specific configs\n\n---\n\n## Common Use Cases\n\n**Load `references\u002Fcommon-patterns.md` for 10 real-world cron patterns including database cleanup, API data collection, daily reports generation, cache warming, monitoring & health checks, data synchronization, backup automation, sitemap generation, webhook processing, and scheduled notifications.**\n\n---\n\n## TypeScript Types\n\n```typescript\n\u002F\u002F Scheduled event controller\ninterface ScheduledController {\n  readonly cron: string;\n  readonly type: string;\n  readonly scheduledTime: number;\n}\n\n\u002F\u002F Execution context\ninterface ExecutionContext {\n  waitUntil(promise: Promise\u003Cany>): void;\n  passThroughOnException(): void;\n}\n\n\u002F\u002F Scheduled handler\nexport default {\n  async scheduled(\n    controller: ScheduledController,\n    env: Env,\n    ctx: ExecutionContext\n  ): Promise\u003Cvoid>;\n}\n```\n\n---\n\n## Limits & Pricing\n\n### Limits\n\n| Feature | Free Plan | Paid Plan |\n|---------|-----------|-----------|\n| **Cron triggers per Worker** | 3 | Higher (check docs) |\n| **CPU time per execution** | 10 ms (avg) | 30 seconds (default), 5 min (max) |\n| **Wall clock time** | 30 seconds | 15 minutes |\n| **Memory** | 128 MB | 128 MB |\n\n### Pricing\n\nCron triggers use **Standard Workers pricing**:\n\n- **Workers Paid Plan**: $5\u002Fmonth required\n- **Requests**: $0.30 per million requests (after 10M free)\n- **CPU Time**: $0.02 per million CPU-ms (after 30M free)\n\n**Cron execution = 1 request**\n\n**Example:**\n- Cron runs every hour (24 times\u002Fday)\n- 30 days × 24 executions = 720 executions\u002Fmonth\n- Average 50ms CPU time per execution\n\n**Cost:**\n- Requests: 720 (well under 10M free)\n- CPU time: 720 × 50ms = 36,000ms (under 30M free)\n- **Total: $5\u002Fmonth (just subscription)**\n\n**High frequency example:**\n- Cron runs every minute (1440 times\u002Fday)\n- 30 days × 1440 = 43,200 executions\u002Fmonth\n- Still under free tier limits\n- **Total: $5\u002Fmonth**\n\n---\n\n## Troubleshooting\n\n### Issue: Cron not executing\n\n**Possible causes:**\n1. Changes not propagated yet (wait 15 minutes)\n2. Invalid cron expression\n3. Handler not exported correctly\n4. Worker not deployed\n\n**Solution:**\n\n```bash\n# Re-deploy\nbunx wrangler deploy\n\n# Wait 15 minutes\n\n# Check dashboard\n# Workers & Pages > [Worker] > Cron Triggers\n\n# Check logs\n# Workers & Pages > [Worker] > Logs > Real-time Logs\n```\n\n---\n\n### Issue: Handler executes but fails\n\n**Possible causes:**\n1. Uncaught error in handler\n2. CPU time limit exceeded\n3. Missing environment bindings\n4. Network timeout\n\n**Solution:**\n\n```typescript\nexport default {\n  async scheduled(controller, env, ctx) {\n    try {\n      await yourTask(env);\n    } catch (error) {\n      \u002F\u002F Log detailed error\n      console.error('Handler failed:', {\n        error: error.message,\n        stack: error.stack,\n        cron: controller.cron,\n        time: new Date(controller.scheduledTime),\n      });\n\n      \u002F\u002F Send alert\n      ctx.waitUntil(sendAlert(error));\n\n      \u002F\u002F Re-throw to mark as failed\n      throw error;\n    }\n  },\n};\n```\n\nCheck logs in dashboard for error details.\n\n---\n\n### Issue: Wrong execution time\n\n**Cause:** UTC vs. local timezone confusion\n\n**Solution:**\n\nConvert your desired local time to UTC:\n\n```typescript\n\u002F\u002F Want 9am PST (UTC-8)?\n\u002F\u002F 9am PST = 5pm UTC (17:00)\n\n{\n  \"triggers\": {\n    \"crons\": [\"0 17 * * *\"]\n  }\n}\n```\n\n**Tools:**\n- [World Clock Converter](https:\u002F\u002Fwww.timeanddate.com\u002Fworldclock\u002Fconverter.html)\n- Remember DST changes (PST vs PDT)\n\n---\n\n### Issue: Local testing not working\n\n**Possible causes:**\n1. Missing `--test-scheduled` flag\n2. Wrong endpoint (should be `\u002F__scheduled`)\n3. Python Worker (use `\u002Fcdn-cgi\u002Fhandler\u002Fscheduled`)\n\n**Solution:**\n\n```bash\n# Correct: Start with flag\nbunx wrangler dev --test-scheduled\n\n# In another terminal\ncurl \"http:\u002F\u002Flocalhost:8787\u002F__scheduled?cron=0+*+*+*+*\"\n```\n\n---\n\n## Production Checklist\n\nBefore deploying cron triggers to production:\n\n- [ ] Cron expression validated on [Crontab Guru](https:\u002F\u002Fcrontab.guru\u002F)\n- [ ] Handler named exactly `scheduled` in default export\n- [ ] ES modules format used (not Service Worker)\n- [ ] Local timezone converted to UTC\n- [ ] Error handling implemented with logging\n- [ ] Alerts configured for failures\n- [ ] CPU limits increased if needed (`limits.cpu_ms`)\n- [ ] Environment bindings tested\n- [ ] Tested locally with `--test-scheduled`\n- [ ] Deployment tested in staging environment\n- [ ] Waited 15 minutes after deploy for propagation\n- [ ] Verified execution in dashboard logs\n- [ ] Monitoring and alerting configured\n- [ ] Documentation updated with schedule details\n\n---\n\n## Related Documentation\n\n- **Cloudflare Cron Triggers**: https:\u002F\u002Fdevelopers.cloudflare.com\u002Fworkers\u002Fconfiguration\u002Fcron-triggers\u002F\n- **Scheduled Handler API**: https:\u002F\u002Fdevelopers.cloudflare.com\u002Fworkers\u002Fruntime-apis\u002Fhandlers\u002Fscheduled\u002F\n- **Cron Trigger Examples**: https:\u002F\u002Fdevelopers.cloudflare.com\u002Fworkers\u002Fexamples\u002Fcron-trigger\u002F\n- **Multiple Cron Triggers**: https:\u002F\u002Fdevelopers.cloudflare.com\u002Fworkers\u002Fexamples\u002Fmultiple-cron-triggers\u002F\n- **Wrangler Triggers Command**: https:\u002F\u002Fdevelopers.cloudflare.com\u002Fworkers\u002Fwrangler\u002Fcommands\u002F#triggers\n- **Workers Pricing**: https:\u002F\u002Fdevelopers.cloudflare.com\u002Fworkers\u002Fplatform\u002Fpricing\u002F\n- **Workflows Integration**: https:\u002F\u002Fdevelopers.cloudflare.com\u002Fworkflows\u002F\n- **Crontab Guru** (validator): https:\u002F\u002Fcrontab.guru\u002F\n- **Time Zone Converter**: https:\u002F\u002Fwww.timeanddate.com\u002Fworldclock\u002Fconverter.html\n\n---\n\n**Last Updated**: 2025-10-23\n**Version**: 1.0.0\n**Maintainer**: Claude Skills Maintainers | maintainers@example.com\n",{"name":5,"license":15,"metadata":24,"description":7},{"keywords":25},[26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41],"cloudflare cron","cron triggers","scheduled workers","scheduled handler","periodic tasks","background jobs","scheduled tasks","cron expression","wrangler crons","scheduled event","green compute","workflow triggers","maintenance tasks","scheduled() handler","ScheduledController","UTC timezone","main","c475fc64e94e803b50d14a791dfee8853fbb2c5c","integrations\u002Fclaude-skills-secondsky\u002Fplugins\u002Fcloudflare-cron-triggers\u002Fskills\u002Fcloudflare-cron-triggers","https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory","https:\u002F\u002Fgithub.com\u002FElogic360","2026-11-08 22:21:22",{"source":8,"skillName":5,"commands":49,"prompt":59,"zipAvailable":60},[50,53,56],{"tool":51,"command":52},"npx","npx skills add Elogic360\u002Fsoftware-factory --skill cloudflare-cron-triggers",{"tool":54,"command":55},"bunx","bunx skills add Elogic360\u002Fsoftware-factory --skill cloudflare-cron-triggers",{"tool":57,"command":58},"pnpm","pnpm dlx skills add Elogic360\u002Fsoftware-factory --skill cloudflare-cron-triggers","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fintegrations\u002Fclaude-skills-secondsky\u002Fplugins\u002Fcloudflare-cron-triggers\u002Fskills\u002Fcloudflare-cron-triggers\u002FSKILL.md",true,[62,68,72,76,80,84,90,94,98,102],{"path":63,"resourceType":64,"resourceTypeDesc":65,"sizeBytes":66,"sourceHtmlUrl":67},"references\u002Fcommon-patterns.md","REFERENCE","参考文档",15985,"https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fintegrations\u002Fclaude-skills-secondsky\u002Fplugins\u002Fcloudflare-cron-triggers\u002Fskills\u002Fcloudflare-cron-triggers\u002Freferences\u002Fcommon-patterns.md",{"path":69,"resourceType":64,"resourceTypeDesc":65,"sizeBytes":70,"sourceHtmlUrl":71},"references\u002Fcron-expressions-reference.md",8870,"https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fintegrations\u002Fclaude-skills-secondsky\u002Fplugins\u002Fcloudflare-cron-triggers\u002Fskills\u002Fcloudflare-cron-triggers\u002Freferences\u002Fcron-expressions-reference.md",{"path":73,"resourceType":64,"resourceTypeDesc":65,"sizeBytes":74,"sourceHtmlUrl":75},"references\u002Fintegration-patterns.md",11219,"https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fintegrations\u002Fclaude-skills-secondsky\u002Fplugins\u002Fcloudflare-cron-triggers\u002Fskills\u002Fcloudflare-cron-triggers\u002Freferences\u002Fintegration-patterns.md",{"path":77,"resourceType":64,"resourceTypeDesc":65,"sizeBytes":78,"sourceHtmlUrl":79},"references\u002Ftesting-guide.md",11156,"https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fintegrations\u002Fclaude-skills-secondsky\u002Fplugins\u002Fcloudflare-cron-triggers\u002Fskills\u002Fcloudflare-cron-triggers\u002Freferences\u002Ftesting-guide.md",{"path":81,"resourceType":64,"resourceTypeDesc":65,"sizeBytes":82,"sourceHtmlUrl":83},"references\u002Fwrangler-config.md",8136,"https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fintegrations\u002Fclaude-skills-secondsky\u002Fplugins\u002Fcloudflare-cron-triggers\u002Fskills\u002Fcloudflare-cron-triggers\u002Freferences\u002Fwrangler-config.md",{"path":85,"resourceType":86,"resourceTypeDesc":87,"sizeBytes":88,"sourceHtmlUrl":89},"templates\u002Fbasic-scheduled.ts","SCRIPT","脚本",3508,"https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fintegrations\u002Fclaude-skills-secondsky\u002Fplugins\u002Fcloudflare-cron-triggers\u002Fskills\u002Fcloudflare-cron-triggers\u002Ftemplates\u002Fbasic-scheduled.ts",{"path":91,"resourceType":86,"resourceTypeDesc":87,"sizeBytes":92,"sourceHtmlUrl":93},"templates\u002Fhono-with-scheduled.ts",5313,"https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fintegrations\u002Fclaude-skills-secondsky\u002Fplugins\u002Fcloudflare-cron-triggers\u002Fskills\u002Fcloudflare-cron-triggers\u002Ftemplates\u002Fhono-with-scheduled.ts",{"path":95,"resourceType":86,"resourceTypeDesc":87,"sizeBytes":96,"sourceHtmlUrl":97},"templates\u002Fmultiple-crons.ts",8595,"https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fintegrations\u002Fclaude-skills-secondsky\u002Fplugins\u002Fcloudflare-cron-triggers\u002Fskills\u002Fcloudflare-cron-triggers\u002Ftemplates\u002Fmultiple-crons.ts",{"path":99,"resourceType":86,"resourceTypeDesc":87,"sizeBytes":100,"sourceHtmlUrl":101},"templates\u002Fscheduled-with-bindings.ts",10952,"https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fintegrations\u002Fclaude-skills-secondsky\u002Fplugins\u002Fcloudflare-cron-triggers\u002Fskills\u002Fcloudflare-cron-triggers\u002Ftemplates\u002Fscheduled-with-bindings.ts",{"path":103,"resourceType":104,"resourceTypeDesc":105,"sizeBytes":106,"sourceHtmlUrl":107},"templates\u002Fwrangler-cron-config.jsonc","OTHER","其他",7158,"https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fintegrations\u002Fclaude-skills-secondsky\u002Fplugins\u002Fcloudflare-cron-triggers\u002Fskills\u002Fcloudflare-cron-triggers\u002Ftemplates\u002Fwrangler-cron-config.jsonc",[109,117,124,131,138,145],{"skillNo":110,"name":111,"nameZh":6,"description":112,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":113,"licenseFileUrl":6,"sourceHtmlUrl":114,"categories":115,"keywords":116,"publishedAt":19},"01M79G206MT3J6S0GY3C45P2KV","vss-summarize-video","Use to summarize a recorded video via the LVS summarization microservice (HITL-gated) with a VLM fallback. Not for report generation or live RTSP captioning.","Apache-2.0","https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fvss-summarize-video\u002FSKILL.md",[],[],{"skillNo":118,"name":119,"nameZh":6,"description":120,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":113,"licenseFileUrl":6,"sourceHtmlUrl":121,"categories":122,"keywords":123,"publishedAt":19},"01M79G1WN63PGRE8CKD47WEBQ5","vss-setup-video-analytics-api","Use to deploy the vss-video-analytics-api REST service standalone (config-source, data-log bind, Elasticsearch, optional Kafka). Not for full warehouse deploy.","https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fvss-setup-video-analytics-api\u002FSKILL.md",[],[],{"skillNo":125,"name":126,"nameZh":6,"description":127,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":113,"licenseFileUrl":6,"sourceHtmlUrl":128,"categories":129,"keywords":130,"publishedAt":19},"01M79G1S9F7VY3EF6H53PRP5AN","vss-setup-behavior-analytics","Use to deploy the vss-behavior-analytics service standalone (entrypoint, config-source, optional calibration). Not for the full warehouse deploy.","https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fvss-setup-behavior-analytics\u002FSKILL.md",[],[],{"skillNo":132,"name":133,"nameZh":6,"description":134,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":113,"licenseFileUrl":6,"sourceHtmlUrl":135,"categories":136,"keywords":137,"publishedAt":19},"01M79G1N1S1Y27PFZPYMNK1MTQ","vss-search-archive","Use this skill to run top-level VSS fusion search on archived video, or to ingest video files \u002F RTSP streams for search. Do NOT use for ad-hoc visual Q&A (use vss-ask-video), live captioning (use vss-deploy-dense-captioning), or video summarization and reports (use vss-summarize-video).","https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fvss-search-archive\u002FSKILL.md",[],[],{"skillNo":139,"name":140,"nameZh":6,"description":141,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":113,"licenseFileUrl":6,"sourceHtmlUrl":142,"categories":143,"keywords":144,"publishedAt":19},"01M79G1H6WN0Q6C0VCAXCZX6B7","vss-query-analytics","Use this skill when reading video-analytics metrics, incidents, alerts, and sensor data via the VA-MCP server (port 9901). Not for live VLM or incident-range narrative reports.","https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fvss-query-analytics\u002FSKILL.md",[],[],{"skillNo":146,"name":147,"nameZh":6,"description":148,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":113,"licenseFileUrl":6,"sourceHtmlUrl":149,"categories":150,"keywords":151,"publishedAt":19},"01M79G1DYPNXQS7QHZ0AAF5FX5","vss-manage-video-io-storage","Use to call the VIOS REST API (sensor list, timelines, clip extraction, snapshots, add\u002Fdelete sensors and streams). Not for VLM inference or search.","https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fvss-manage-video-io-storage\u002FSKILL.md",[],[]]