Reputation: 2274
I want to run same piece of code 3 times in a day: 10 AM, 1 PM & 6 PM.
Code for running particular code at let's day 10 AM is as follows:
var schedule = require('node-schedule');
var rule = new schedule.RecurrenceRule();
rule.dayOfWeek = [0, 6];
rule.hour = 10;
rule.minute = 0;
var j = schedule.scheduleJob(rule, function(){
console.log('Yup!');
});
Do I need to copy paste same function 3 times or is there any way to tweak this? I can't use setInterval because intervals are not uniform.
Upvotes: 2
Views: 2962
Reputation: 42325
You just need to set the hour
property correctly:
rule.hour = [10, 13, 18];
Upvotes: 7