2

正在处理一个调度过程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);
4

0 回答 0