Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloudflare cron triggers documentation does not include code sample #20632

Open
thomas-desmond opened this issue Mar 7, 2025 · 0 comments · May be fixed by #20637
Open

Cloudflare cron triggers documentation does not include code sample #20632

thomas-desmond opened this issue Mar 7, 2025 · 0 comments · May be fixed by #20637
Assignees
Labels
content:new Request for new/missing content documentation Documentation edits product:workers Related to Workers product

Comments

@thomas-desmond
Copy link
Contributor

thomas-desmond commented Mar 7, 2025

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

@thomas-desmond thomas-desmond added content:new Request for new/missing content documentation Documentation edits labels Mar 7, 2025
@github-actions github-actions bot added the product:workers Related to Workers product label Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content:new Request for new/missing content documentation Documentation edits product:workers Related to Workers product
Projects
None yet
6 participants