-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
content:newRequest for new/missing contentRequest for new/missing contentdocumentationDocumentation editsDocumentation editsproduct:workersRelated to Workers productRelated to Workers product
Description
Proposed changes
Please assign me to this issue.
Add the following code sample to the page to highlight the scheduled function required for cron triggers in Workers.
export default {
async fetch(request, env, ctx): Promise<Response> {
return new Response('Hello World!');
},
/**
* This function is triggered by a Cloudflare Cron Trigger.
* It runs at specified intervals to perform scheduled tasks.
*/
async scheduled(event, env, ctx): Promise<void> {
// Example scheduled task: Log the current date and time
const currentTime = new Date().toISOString();
console.log(`Scheduled task executed at: ${currentTime}`);
}
} satisfies ExportedHandler<Env>;
Subject Matter
Workers cron triggers
Content Location
Additional information
No response
Metadata
Metadata
Labels
content:newRequest for new/missing contentRequest for new/missing contentdocumentationDocumentation editsDocumentation editsproduct:workersRelated to Workers productRelated to Workers product