18 lines
368 B
Go
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()
|
|
}
|