Task Schedule with Node Plan

I am using a node module called node-schedule

I have this feature, it is expected to fire ONCE at the beginning of each quarter.

var rule = {hour: 0, minute: 0, day: 1, month: [0, 3, 6, 9]};

var logCost = schedule.scheduleJob(rule, function(){
  console.log('logCost output this shit at: ' + dateFormat(Date(), 'isoTime'));
});

The problem is that the function simply continues to run throughout the day (the first day of the month). How to rewrite this to execute only once, maybe something is wrong with my rule variable, but I don’t see that.

+4
source share
2 answers

try with this:

var rule = {hour: 00, minute: 01, dayOfWeek: 01, month: [0, 3, 6, 9]};
var logCost = schedule.scheduleJob(rule, function(){
          console.log('logCost output this shit at: ' + dateFormat(Date(), 'isoTime'));
});

Check here: https://github.com/mattpat/node-schedule

It should be "dayOfWeek", not "day."

+1
source

:

var logCost = schedule.scheduleJob('1 0 * * *', function(){
  console.log('logCost output this shit at: ' + new Date());
});

00:01 (12:01).

0

All Articles