@elara-services/cron

Welcome to the cron package


Links:

Docs Docs

Discord Support

Patreon Patreon

PayPal PayPal


Getting Started

    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.

Add Cron Job

    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)
});

Remove Cron Job

    client.remove("dailyjob"); // Remove the job and stop the process. 
// Use the name of the cronjob when you created it.

Remove ALL Cron Jobs

    client.removeAll(); // Removes all cron jobs and stops the processes

View Cron Job

    const job = client.get("dailyjob");
// use 'job' to view it's details etc.

List Cron Jobs

    const jobs = client.list();
// Returns an array-object of the name and jobs

Generated using TypeDoc