Deno Cron
在 Github 上編輯
警告:這是一個不穩定的 API,隨時可能變更或移除。
Deno Cron 是一個內建於 Deno 執行時環境的 cron 任務排程器,可在 Deno Deploy 上零設定運作。它沒有重疊的 cron 執行,並在例外情況下具有自動處理常式重試。
建立一個名為「記錄訊息」的 cron 工作,每分鐘執行一次。
Deno.cron("Log a message", "* * * * *", () => {
console.log("This will print once a minute.");
});
建立一個具有以毫秒為單位的退避排程的 cron 工作。
Deno.cron("Retry example", "* * * * *", {
backoffSchedule: [1000, 5000, 10000],
}, () => {
throw new Error("Deno.cron will retry this three times, to no avail!");
});
在本機使用 Deno CLI 執行此範例
deno run --unstable-cron https://deno-docs.dev.org.tw/examples/scripts/cron.ts