正在使用node.js
为此我写了一个样本script.js
文件并且没有问题正确执行
// it executes every sunday at 14:29PM
var rule = {hour: 14, minute: 29, dayOfWeek: 0};
schedule.scheduleJob(rule, function(){
console.log("Execute me at sunday .............")
});
以上代码只会在星期天下午14:29执行。
但是使用上面相同的代码时,它每次执行
var schedule = require('node-schedule');
var http = require('http');
var jobScedule = function (time, jobid) {
schedule.scheduleJob(time, function () {
console.log("execute me at sunday") // it executes every time when i called this function
console.log(time);
});
}
exports.jobScedule = jobScedule;
我打电话给另一个档案
var objSchedule = require('./script.js');
var rule = {hour: 23, minute: 60, dayOfWeek: 0};
objSchedule.jobScedule(rule, jobid);