定时node-schedule 模块的使用
You can install using npm.
npm install node-schedule
var schedule = require('node-schedule'); var j = schedule.scheduleJob('42 * * * *', function(){ console.log('The answer to life, the universe, and everything!'); });
42分钟执行一次
* * * * * *
┬┬┬┬┬┬
││││││
│││││└星期(0 - 7)(0或7日)
││││└─────月(1 - 12)
│││└──────────天月(1 - 31)
││└───────────────小时(0 - 23)
│└────────────────────分钟(0 - 59)
└─────────────────────────秒(0 - 59,可选)