2015-10-27 90 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瞭解更多模式。

相關問題