https://www.npmjs.org/package/node-schedule
Code:
var http = require('http');
var port = process.env.PORT || 8080;
var schedule = require('node-schedule');
var rule = new schedule.RecurrenceRule();
rule.dayOfWeek = [0, 6];
rule.hour = 12;
rule.minute = 25;
var j = schedule.scheduleJob(rule, function(){
console.log('Yup!');
});
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello World\n");
}).listen(port);
console.log("Node server listening on port " + port);
I have the started the server from command line so this should print "Yup!" on console at 12.25 but it didn't. What can be the problem?
Use this:
rule.dayOfWeek = [0, new schedule.Range(1, 6)];
Instead of:
rule.dayOfWeek = [0, 6]; this one