0

Above is my code, which I want to use it as notification scheduler, but not working

  const nodeSchedule = require('node-schedule');

  var a = new Date();
  let rule2 = new nodeSchedule.RecurrenceRule();

  rule2.second = a.getSeconds();
  rule2.minute = a.getMinutes() + 2;
  rule2.hour = a.getHours();
  rule2.year = a.getFullYear();
  rule2.month = a.getMonth() + 1; // beware: January = 0; February = 1, etc.
  rule2.date = a.getDate();
  rule2.tz = 'America/Araguaina';

  var job = nodeSchedule.scheduleJob('demo', rule2, function () {
    console.log('worked..');
  });
  console.log(job)
shiVam_Mak
  • 39
  • 1
  • 8

1 Answers1

1

i advice you to use cron instead of node-schedule. it gives you more control.

1.you can change cron time without changing the code(SetTime) 2.you have a lot of methods for this library like fireOnTick addCallback etc. 3.can start and stop job dynamically. 4.you have access to onTick and onComplete functions https://www.npmjs.com/package/cron 5.you can set the timezone easily.

Pratheek Reddy
  • 103
  • 1
  • 8