wireguard-dashboard/cron_task/cron.go
coward a424a5e0b3
All checks were successful
continuous-integration/drone/tag Build is passing
🎨监听任务更改为定时任务
2024-06-13 17:06:23 +08:00

18 lines
368 B
Go

package cron_task
import (
"gitee.ltd/lxh/logger/log"
"github.com/go-co-op/gocron/v2"
"time"
)
func StartCronTask() {
s, err := gocron.NewScheduler()
if err != nil {
log.Errorf("初始化定时任务失败: %v", err.Error())
return
}
_, _ = s.NewJob(gocron.DurationJob(time.Hour), gocron.NewTask(offlineMonitoring)) // 每小时执行一次
s.Start()
}