如何设置每天早上12点的节点安排

Ann*_*nna 5 schedule node.js npm

我正在使用node-schedule来安排我的任务.现在我需要每天早上12点安排一份工作.下面给出的是我正在使用的代码,

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

这不适合我.

任何帮助赞赏.提前致谢.

Fur*_*ran 9

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

var CronJob = require('cron').CronJob;
var job = new CronJob('00 00 12 * * 0-6', 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. */
);
Run Code Online (Sandbox Code Playgroud)

阅读文档了解更多模式.

  • 只需使用“00 00 00 * * *”即可 (2认同)