const { CronClient } = require("@elara-services/cron");
const client = new CronClient();
// By default the timeZone will use `America/Los_Angeles`
// OR
const client = new CronClient("TIMEZONE_HERE");
// To have cron use a certain time to use.
client.add({
name: "dailyjob", // Name of the job
time: "1 0 0 * * *", // Every day at midnight
run: async () => {
// Code to run when the time comes.
},
timeZone: "America/Los_Angeles", // The timeZone to use for this cronjob, otherwise it will use the default one (OPTIONAL)
onStartup: true, // Run this job instantly (OPTIONAL, DEFAULT: false)
});
client.remove("dailyjob"); // Remove the job and stop the process.
// Use the name of the cronjob when you created it.
client.removeAll(); // Removes all cron jobs and stops the processes
const job = client.get("dailyjob");
// use 'job' to view it's details etc.
const jobs = client.list();
// Returns an array-object of the name and jobs
Generated using TypeDoc