Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
function Deno.cron
Unstable

Create a cron job that will periodically execute the provided handler callback based on the specified schedule.

Deno.cron("sample cron", "*\/20 * * * *", () => {
  console.log("cron job executed");
});

backoffSchedule option can be used to specify the retry policy for failed executions. Each element in the array represents the number of milliseconds to wait before retrying the execution. For example, [1000, 5000, 10000] means that a failed execution will be retried at most 3 times, with 1 second, 5 seconds, and 10 seconds delay between each retry.

Parameters

name: string
schedule: string
handler: () => Promise<void> | void
optional
options: { backoffSchedule?: number[]; signal?: AbortSignal; }

Returns

Promise<void>