Skip to content
Workers
Visit Workers on GitHub
Set theme to dark (⇧+D)

Multiple Cron Triggers

Set multiple Cron Triggers on three different schedules.

addEventListener('scheduled', event => {
event.waitUntil(triggerEvent(event.cron))
})
async function triggerEvent(event.cron) {
// Write code for updating your API
switch (event.cron) {
// You can set up to three schedules maximum.
case "*/3 * * * *":
// Every three minutes
await updateAPI();
break;
case "*/10 * * * *":
// Every ten minutes
await updateAPI2();
break;
case "*/45 * * * *":
// Every forty-five minutes
await updateAPI3();
break;
}
console.log("cron processed")
}