cron 示例源码
这些文件来自仓库的 examples/cron,可结合对应中文文档阅读和运行。
wrangler.jsonc
{
"name": "cron",
"main": "index.js",
"compatibility_date": "2026-01-01",
"triggers": { "crons": ["* * * * *"] }
}
index.js
export default {
async fetch(request, env) {
return new Response("The cron runs once a minute.\n");
},
async scheduled(controller, env, ctx) {
console.log("cron", controller.scheduledTime);
},
};