Complete the code to import the cron scheduler from the Deno standard library.
import { [1] } from "https://deno.land/std@0.203.0/cron/mod.ts";
The Cron class is imported from the Deno cron module to create scheduled tasks.
Complete the code to create a cron job that runs every minute.
const cron = new Cron({
cronTime: "[1]",
onTick: () => console.log("Task running every minute"),
});Deno's cron module uses 6-field expressions (second, minute, hour, day, month, weekday). The expression 0 * * * * * runs the task once every minute at second 0.
Fix the error in the code to start the cron job.
cron.[1]();run() or execute() which do not exist.begin() which is not a method.The start() method is used to begin the cron job in Deno's cron module.
Fill both blanks to create a cron job that runs every day at 7:30 AM and logs a message.
const dailyJob = new Cron({
cronTime: "[1]",
onTick: () => console.[2]("Good morning! Time to start your day."),
});console.info instead of console.log.The cron expression "0 30 7 * * *" runs the job at 7:30:00 AM every day (sec=0, min=30, hour=7). The console.log method outputs the message to the console.
Fill all three blanks to create a cron job that runs every Monday at 9:00 AM, logs a start message, and then stops itself.
const weeklyJob = new Cron({
cronTime: "[1]",
onTick: () => {
console.[2]("Weekly job started.");
weeklyJob.[3]();
},
});start() instead of stop() to end the job.The cron expression "0 0 9 * * 1" runs the job at 9:00:00 AM every Monday. console.log prints the message, and stop() stops the cron job after running.
