published fresh until

Cloudflare Workers: how do I deploy cron jobs with cost limits?

Summary Pair a scheduled handler with UTC cron expressions, isolate Preview resources, and store credentials as secrets. Set a Workers spending limit with its account-wide outage risk in mind: delayed enforcement and separate product charges prevent an exact bill ceiling.

Not for a guaranteed maximum bill across storage, queues and external APIs.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: implement scheduled() and define triggers.crons in Wrangler; express the schedule in UTC (Cron Triggers).

Short answer

Use Cron Triggers for periodic execution, Preview settings with separate resources for deployment checks, and encrypted secret bindings for credentials (cron, Previews, secrets). Add an account-wide spending limit for Workers usage, while allowing for enforcement delay and separate product charges (spending limits).

Choose / don't choose

  • Preview: use for isolated changes; Cron Triggers do not invoke its scheduled handler, so do not use its timer behavior as production evidence (Preview guide).
  • Spending limit: use when stopping every Worker in the account is acceptable; it is not an exact maximum bill (limits).

Settings that matter

Setting or flagValue / defaultApplies toSource
triggers.cronsExample: ["0 15 1 * *"], first day of each month at 15:00 UTCWrangler Cron Trigger configurationCron
previewsSeparate Preview settings; use separate mutable resourcesWorker PreviewsGuide
Secret bindingEncrypted sensitive value rather than plaintext configurationWorker credentialsSecrets
Spending limitUser-selected request and CPU usage threshold after included usageWhole Workers account; subscription excludedLimits

Order of operations

1. Add the scheduled handler and cron configuration (Cron). 2. Invoke the handler locally through /cdn-cgi/local/scheduled on the development server's port (handler reference). 3. Configure separate Preview resources before npx wrangler preview. Preview URLs are public by default; apply Access for private content (Preview guide). 4. Choose secret deployment behavior deliberately: wrangler secret put deploys immediately; wrangler versions secret put creates a version for later deployment (secrets). 5. Configure the spending threshold after accounting for the outage tradeoff and separate product charges (limits).

Known failures and fixes

SymptomCauseFixSource
Preview timer never firesCron Triggers do not invoke Preview scheduled handlersExercise scheduled logic through the local invocation routePreview, handler
All Workers stop accepting invocationsAccount spending threshold takes effectCheck Billing > Spend Management; raise or remove the limit to resumeLimits
Removing cron configuration leaves an old timerOmitted cron configuration preserves deployed triggersSet crons to an empty array to remove all triggersCron

Missing

  • What exact threshold fits this job? No workload volume or budget is supplied.
  • How should retries and duplicate runs affect application state? These references do not supply this job's transaction design.
  • How can the entire bill be capped exactly? Workers limits exclude other product charges and enforcement can lag (limits).

Checked

2026-11-23; sources read:

Started from a post by @WhatWorks editors, packaged by the editor.

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Cloudflare Workers: how do I deploy cron jobs with cost limits?
Summary: Pair a scheduled handler with UTC cron expressions, isolate Preview resources, and store credentials as secrets. Set a Workers spending limit with its account-wide outage risk in mind: delayed enforcement and separate product charges prevent an exact bill ceiling.
Copy for agent
get the whatworks thread case-cloudflare-workers-cron-triggers-secrets-safe-deploy-bill-protection and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread case-cloudflare-workers-cron-triggers-secrets-safe-deploy-bill-protection
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks