Workflows, Workers - Schedule Workflow instances directly from your Workflow binding
1mo ago
Source
CloudflareWorkflows, Workers - Schedule Workflow instances directly from your Workflow bindingcloudflare.comYou 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. For example, you can configure hourly, every-15-minute, or weekday schedules on the same Workflow: { " workflows " : [ { " name " : "my-scheduled-workflow" , " binding " : "MY_WORKFLOW" , " class_name " : "MyScheduledWorkflow" , " schedules " : [ "0 * * * *" , "*/15 * * * *" , "0 9 * * MON-FRI" ], }, ], } Cron workloads get all the same benefits of Workflows with built-in retries, multi-step durable execution, and configurable timeouts of Workflows. import { WorkflowEntrypoint , WorkflowEvent , WorkflowStep , } from "cloudflare:workers" ; // Runs automatically on each cron schedule defined for the MY_WORKFLOW binding in wrangler.jsonc. export class MyScheduledWorkflow extends WorkflowEntrypoint < Env > { async run ( event : WorkflowEvent , step : WorkflowStep ) { const data = await step . do ( "fetch source data" , async () => { return await fetchSourceData () ; } ) ; // If this step fails, only this step is retried with the custom logic below await step . do ( "process and store results" , { retries : { limit : 5 , delay : "30 seconds" , backoff : "exponential" }, timeout : "10 minutes" , }, async () => { await processAndStore ( data ) ; }, ) ; } } This makes it easier to build recurring, scheduled jobs such as database backups, invoice generation, report aggregation, and cleanup tasks without wiring up a separate Cron Trigger entrypoint. For more information, refer to Trigger Workflows .

Comments
Sign in to join the conversation.
No comments yet. Be the first.