Cron Triggers·续

Test Cron Triggers locally

Use cf dev, wrangler dev, or the Cloudflare Vite plugin to test Cron Triggers locally. You can use Local Explorer or send an HTTP request.

Cron Trigger testing in Local Explorer requires Wrangler 4.139.0 or later, or Cloudflare Vite plugin 1.60.0 or later. These requirements also apply to the development server started by cf dev.

Use Local Explorer

Local Explorer displays the exact Cron Triggers configured for the active environment. It can also test ad hoc expressions without changing your configuration.

To test a configured expression, define at least one Cron Trigger for the active environment. You can test an ad hoc expression without configuring one.

  1. Open Local Explorer and select the Worker you want to test.
  2. Select Cron Triggers > Configured Crons.
  3. Select Now or add a scheduled time preset.
  4. Select Trigger next to the expression you want to test.
  5. Review the handler outcome, noRetry() status, dispatched expression, and scheduled time.

Full invocation logs are available in the development session that owns the Worker. That session must have Observability turned on.

Each invocation is a one-off local test. Local development does not run Cron Triggers automatically.

To test an expression that is not configured, select Cron Triggers > Ad-Hoc Triggers. Ad hoc triggers stay in your browser and do not modify deployed Cron Triggers.

Use an HTTP request

Your local development server exposes two endpoints for scheduled invocations. The following examples use port 8787. Use the port printed by your development server, including when you start it with cf dev. Vite uses port 5173 by default.

Use the scheduled route

Send a request to /cdn-cgi/local/scheduled to invoke a scheduled handler.

curl "http://localhost:8787/cdn-cgi/local/scheduled"

By default, the endpoint returns the scheduled handler outcome as text. To return the structured scheduled handler result as JSON, pass ?format=json.

curl "http://localhost:8787/cdn-cgi/local/scheduled?format=json"
{
  "outcome": "ok",
  "noRetry": false
}

The noRetry field is true when the scheduled handler calls controller.noRetry().

To simulate different cron patterns, a cron query parameter can be passed in.

curl "http://localhost:8787/cdn-cgi/local/scheduled?cron=*+*+*+*+*"

Optionally, you can also pass a time query parameter to override controller.scheduledTime in your scheduled event listener.

curl "http://localhost:8787/cdn-cgi/local/scheduled?cron=*+*+*+*+*&time=1745856238000"

Use the Local Explorer API

To target an exact Worker available to Local Explorer, send a POST request to /cdn-cgi/local/explorer/api/local/scheduled?worker=<WORKER_NAME>. The worker query parameter must match the exact Worker name. To find available Worker names, send a GET request to /cdn-cgi/local/explorer/api/local/workers.

The JSON body requires a non-empty cron field. The optional scheduled_time field sets controller.scheduledTime using epoch milliseconds. If omitted, it defaults to the current time.

curl -X POST \
  "http://localhost:8787/cdn-cgi/local/explorer/api/local/scheduled?worker=my-worker" \
  -H "Content-Type: application/json" \
  --data '{"cron":"0 * * * *","scheduled_time":1745856238000}'

The response uses the Local Explorer API envelope. Its result includes the handler outcome and noRetry value. A successful API request does not necessarily mean the handler succeeded. Check result.outcome for the invocation result.

View past events

To view the execution history of Cron Triggers, view Cron Events:

  1. In the Cloudflare dashboard, go to the Workers & Pages page. Go to Workers & Pages ↗
  2. In Overview, select your Worker.
  3. Select Settings.
  4. Under Trigger Events, select View events.

Cron Events stores the 100 most recent invocations of the Cron scheduled event. Workers Logs also records invocation logs for the Cron Trigger with a longer retention period and a filter & query interface. If you are interested in an API to access Cron Events, use Cloudflare's GraphQL Analytics API.

Note

It can take up to 30 minutes before events are displayed in Past Cron Events when creating a new Worker or changing a Worker's name.

Refer to Metrics and Analytics for more information.

Remove a Cron Trigger

Via the dashboard

To delete a Cron Trigger on a deployed Worker via the dashboard:

  1. In the Cloudflare dashboard, go to the Workers & Pages page. Go to Workers & Pages ↗
  2. Select your Worker.
  3. Go to Triggers > select the three dot icon next to the Cron Trigger you want to remove > Delete.

Via the Wrangler configuration file

If a Worker is managed with Wrangler, Cron Triggers should be exclusively managed through the Wrangler configuration file.

When deploying a Worker with Wrangler any previous Cron Triggers are replaced with those specified in the triggers array.

  • If the crons property is an empty array then all the Cron Triggers are removed.
  • If the triggers or crons property are undefined then the currently deploy Cron Triggers are left in-place.
{
    "triggers": {
        // Remove all cron triggers:
        "crons": []
    }
}
[triggers]
crons = [ ]

Limits

Refer to Workers limits for the maximum number of Cron Triggers per account.

Green Compute

With Green Compute enabled, your Cron Triggers will only run on Cloudflare points of presence that are located in data centers that are powered purely by renewable energy. Organizations may claim that they are powered by 100 percent renewable energy if they have procured sufficient renewable energy to account for their overall energy use.

Renewable energy can be purchased in a number of ways, including through on-site generation (wind turbines, solar panels), directly from renewable energy producers through contractual agreements called Power Purchase Agreements (PPA), or in the form of Renewable Energy Credits (REC, IRECs, GoOs) from an energy credit market.

Green Compute can be configured at the account level:

  1. In the Cloudflare dashboard, go to the Workers & Pages page. Go to Workers & Pages ↗
  2. In the Account details section, find Compute Setting.
  3. Select Change.
  4. Select Green Compute.
  5. Select Confirm.
  • Triggers - Review Wrangler configuration file syntax for Cron Triggers.
  • Learn how to access Cron Triggers in ES modules syntax for an optimized experience.

Was this helpful?

YesNo

On this page

Cron Triggers·续 - 图1Docs

{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers/configuration/cron-triggers/#page","headline":"Cron Triggers","description":"Enable your Worker to be executed on a schedule.","url":"https://developers.cloudflare.com/workers/configuration/cron-triggers/","inLanguage":"en","image":"https://developers.cloudflare.com/workers/configuration/cron-triggers/og.png?v=b85b0c1fb54550ff","dateModified":"2026-10-17","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}


description: You can add environment variables, which are a type of binding, to attach text strings or JSON values to your Worker. title: Environment variables image: https://developers.cloudflare.com/workers/configuration/environment-variables/og.png?v=490affb3f8811293


Skip to content

Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/workers/llms.txt
Use this file to discover all available pages before exploring further.