一、安装
npm install node-schedule
二、设置定时任务
const schedule = require('node-schedule');
var rule = new schedule.RecurrenceRule();
var time1 = [0, 10, 20, 30, 40, 50] //10倍整数
var time2 = [0, 20, 40] //20倍整数
var time3 = [0, 30] //30倍整数
rule.second = time1//秒 代表每10秒执行一次
// rule.minute = time3//分 每30分执行一次
schedule.scheduleJob(rule, () => {
console.log('scheduleCronstyle:' + new Date());
})