Online Interview Questions

Prepare interviews on Anything, AnyWhere

PHPSCOTS,Blogger, Developer Views: 6880
Scheduling CRON Jobs on Node.js

Cron Jobs are used for scheduling tasks to run on the server.CRON Jobs are most commonly used method to automate tasks on Server. In this article, we will see how to schedule JOBS in Node.js. We are going to use node-schedule package for scheduling JOBS.

node-schedule is a light cron-like scheduler  Package for Node JS.

Installing node-schedule

npm install node-schedule

Setting up Scheduler

var scheduler = require('node-schedule');
var rule = new scheduler.RecurrenceRule();
rule.hour = 7
rule.dayOfWeek = new schedule.Range(0,6)
var dailyJob = schedule.scheduleJob(date, function(){
 console.log('I run on days at 7:00');


Canceling a Scheduled Job on Node

dailyJob .cancel();

You can read more about node-schedule package from

Also Read Node js interview questions

2 thoughts on “Scheduling CRON Jobs on Node.js”

Leave a Reply

Your email address will not be published. Required fields are marked *