有的時候需要根據業務需要,晚上凌晨以后執行某些操作的時候,這個可能會有所幫助,我最近正在研究這個,歡迎共同探討。
github地址:https://github.com/mattpat/node-schedule
一、安裝
var j = schedule.scheduleJob(date, function(){
console.log('The world is going to end today.');
});
取消預設計劃
[code]
j.cancel();
var rule = new schedule.RecurrenceRule();
rule.minute = 42;
var j = schedule.scheduleJob(rule, function(){
console.log('The answer to life, the universe, and everything!');
});
var j = schedule.scheduleJob(rule, function(){
console.log('Today is recognized by Rebecca Black!');
});
五、每秒執行
var times = [];
for(var i=1; i<60; i++){
times.push(i);
}
rule.second = times;
var c=0;
var j = schedule.scheduleJob(rule, function(){
c++;
console.log(c);
});
新聞熱點
疑難解答