node-schedule定时任务

时间:2022-12-15 07:45:02

https://github.com/node-schedule/node-schedule

npm install node-schedule

* * * * * * ┬ ┬ ┬ ┬ ┬ ┬ │ │ │ │ │ | │ │ │ │ │ └ 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 schedule = require('node-schedule'); var j = schedule.scheduleJob('42 * * * *', function(){ console.log('The answer to life, the universe, and everything!'); });

j.cancel();