wireguard-dashboard/cron/cron.go

21 lines
463 B
Go
Raw Normal View History

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(3*time.Minute), gocron.NewTask(task.NetworkClient().ClientOfflineNotify())) // 每三分钟检测离线的客户端并且发送消息
sch.Start()
}