//定时任务每天执行
var rule = new schedule.RecurrenceRule();
rule.hour = 7;//时
rule.minute = 55;//分
rule.second = 50;//秒
var j = schedule.scheduleJob(rule, function () {
getAllUserFromDD().then(function (result) {
return sendInfoToUser(result);
}).then(function (status) {
if (status == 'null') {
console.log('今天没有匹配数据');//看日志发现这句打印了2次,这说明定时函数执行了2次,怎么让他只执行一次?
}
});
});
回复 (8)
F
你可以在isMaster那段逻辑里写的啊
A
if(cluster.isMaster){
//在主进程下支持逻辑
}
N
你只启动一个进程不就好了
N
定时任务单独启动
M
引用 nobody定时任务单独启动
@nobody 好吧, 我现在是记录启动次判断
L
写一个crontab,用curl触发http接口,来触发这个定时任务
M
引用 fantasticsoul你可以在isMaster那段逻辑里写的啊
@fantasticsoul 不知道怎么判断啊,没有头绪
M
引用 leim写一个crontab,用curl触发http接口,来触发这个定时任务
@leim 没有写http接口,直接使用schedule定时执行函数
参与回复
登录后即可参与回复。登录