我想每天以10分钟5分25秒执行该消息,但我尝试了该程序,我收到了错误:
ERROR OCCURED:
throw patterns[5] + ' is a invalid expression for week day';
^
is a invalid expression for week day
代码:
var cron = require('node-cron');
cron.schedule('25 05 10 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31 January,February,March,April,May,June,July,August,September,October,November,December Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday ', function(){
console.log('Time for breakfast');
});
答案 0 :(得分:0)
cron语法如node-cron库页面中所述:
┌────────────── second (optional)
│ ┌──────────── minute
│ │ ┌────────── hour
│ │ │ ┌──────── day of month
│ │ │ │ ┌────── month
│ │ │ │ │ ┌──── day of week
│ │ │ │ │ │
│ │ │ │ │ │
* * * * * *
因此,为了每天10:05:25执行任务,请尝试 25 5 10 * * *
cron.schedule('25 5 10 * * *', function() {
console.log('Time for breakfast');
});