Javascript 每5分钟安排一次作业
我正在使用以下Javascript 每5分钟安排一次作业,javascript,node.js,Javascript,Node.js,我正在使用以下作业调度程序代码打印今天Rebecca Black已识别-每天上午12点 // executes every day at 12:AM var rule = new schedule.RecurrenceRule(); rule.dayOfWeek = [0, new schedule.Range(1, 6)]; rule.hour = 15; rule.minute = 14; schedule.scheduleJob(rule, function() { console.log
作业调度程序
代码打印今天Rebecca Black已识别-代码>每天上午12点
// executes every day at 12:AM
var rule = new schedule.RecurrenceRule();
rule.dayOfWeek = [0, new schedule.Range(1, 6)];
rule.hour = 15;
rule.minute = 14;
schedule.scheduleJob(rule, function() {
console.log(rule);
console.log('Today is recognized by Rebecca Black!---------------------------');
});
如何每5分钟打印一次
我用了下面的方法,但它不起作用
var rule = new schedule.RecurrenceRule();
rule.minute = 5;
schedule.scheduleJob(rule, function() {
console.log(rule);
console.log('Today is recognized by Rebecca Black!---------------------------');
});
上给出了简单而好的示例。您可以使用:
cron格式包括:
* * * * * *
┬ ┬ ┬ ┬ ┬ ┬
│ │ │ │ │ |
│ │ │ │ │ └ day of week (0 - 7) (0 or 7 is Sun)
│ │ │ │ └───── month (1 - 12)
│ │ │ └────────── day of month (1 - 31)
│ │ └─────────────── hour (0 - 23)
│ └──────────────────── minute (0 - 59)
└───────────────────────── second (0 - 59, OPTIONAL)
var event = schedule.scheduleJob("*/5 * * * *", function() {
console.log('This runs every 5 minutes');
});
* * * * * *
┬ ┬ ┬ ┬ ┬ ┬
│ │ │ │ │ |
│ │ │ │ │ └ day of week (0 - 7) (0 or 7 is Sun)
│ │ │ │ └───── month (1 - 12)
│ │ │ └────────── day of month (1 - 31)
│ │ └─────────────── hour (0 - 23)
│ └──────────────────── minute (0 - 59)
└───────────────────────── second (0 - 59, OPTIONAL)