expressweb-scheduler
v1.0.7
Published
This library provides an easy way to schedule recurring tasks in ExpressWebjs and also node/express.
Downloads
5
Maintainers
Readme
Setup
ExpressWebJs Scheduler
The software utility cron also known as cron job is a time-based job scheduler in computer operating systems. Users that set up and maintain software environments use cron to schedule jobs to run periodically at fixed times, dates, or intervals. ExpressWebJs Scheduler makes that really easy to achieve.
Getting started
npm install --save expressweb-scheduler
import expressweb-scheduler and schedule a task
const scheduler = require("expressweb-scheduler");
scheduler.command('sendNewsletter').everySecond().run();
You can also run a closure function using the call method
scheduler.call(()=>{
console.log('this is a closure that is been run every seconds')
}).everySecond().run();
You can also use the cron method:
const scheduler = require("expressweb-scheduler");
scheduler.command('sendNewsletter').cron('* * * * * *').run();
Allowed fields in cron method
# ┌────────────── second (optional)
# │ ┌──────────── minute
# │ │ ┌────────── hour
# │ │ │ ┌──────── day of month
# │ │ │ │ ┌────── month
# │ │ │ │ │ ┌──── day of week
# │ │ │ │ │ │
# │ │ │ │ │ │
# * * * * * *
Allowed Values And Schedule Frequency Options
We've already seen a few examples of how you may configure a task to run at specified intervals. However, there are many more task schedule frequencies that you may assign to a task:
Visit ExpressWebJs Documentation site for more info.
ExpressWebJs is a Node FrameWork with expressive and organised syntax that runs on all major operating systems. It provides the starting point for creating your node project, allowing you to focus more on developing your amazing solution.