2015-10-27 81 views
3

我正在使用节点时间表来安排我的任务。现在我需要每天上午12点安排一份工作。 下面给出的是我使用的代码,如何在上午12点设置每天的节点时间表

var rule3 = schedule.scheduleJob('00 00 00 * * *', function(){ 
    console.log('my test job!'); 
}); 

这不是为我工作。

任何帮助表示赞赏。提前致谢。

回答

7

您可以简单地使用node-cron模块。

var CronJob = require('cron').CronJob; 
var job = new CronJob('00 00 12 * * 1-7', function() { 
    /* 
    * Runs every day 
    * at 12:00:00 AM. 
    */ 
    }, function() { 
    /* This function is executed when the job stops */ 
    }, 
    true, /* Start the job right now */ 
    timeZone /* Time zone of this job. */ 
); 

阅读docs了解更多模式。

相关问题