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)用Cron表达式完成定时器schedule.scheduleJob(‘0 1 * * *’, () => { // something…})关闭定时器APIlet obj = schedule.scheduleJob(‘0 1 * * *’, () => { // something…})obj.close();全局内关闭定时器 – 疑问全局内关闭定时器需要获取到定时器的引用看源码第607行var name = (arguments.length >= 3 && typeof arguments[0] === ‘string’) ? arguments[0] : null; var spec = name ? arguments[1] : arguments[0]; var method = name ? arguments[2] : arguments[1]; var callback = name ? arguments[3] : arguments[2];scheduleJob存在第四个参数,然而readme中没有提及,可知APIscheduleJob(name, spec, method, callback)// name: 定时器的key值 spec: Cron表达式 method: method callback: callback全局内关闭定时器 – 解决首先定义定时器scheduleJob(name, spec, method, callback)在需要关闭的地方,写如下代码function repeatSchedule(str) { for (var i in nodeschedule.scheduledJobs) { // 对比key值, key相同则重复 if (nodeschedule.scheduledJobs[i].name.indexOf(str) > 0) { nodeschedule.scheduledJobs[i].close(); } }}