wireguard-dashboard/cron/cron.go
coward f09d0d2994
Some checks reported errors
continuous-integration/drone/tag Build was killed
🎨调整定时任务执行时间,以及启动时间
2024-12-05 11:49:29 +08:00

20 lines
427 B
Go

package cron
import (
"gitee.ltd/lxh/logger/log"
"github.com/go-co-op/gocron/v2"
"time"
"wireguard-ui/cron/task"
)
func Task() {
sch, err := gocron.NewScheduler(gocron.WithLocation(time.Local))
if err != nil {
log.Errorf("初始化定时任务失败")
return
}
_, _ = sch.NewJob(gocron.DurationJob(1*time.Minute), gocron.NewTask(task.NetworkClient().ClientOfflineNotify)) // 每分钟执行一次
sch.Start()
}