测试定时器

This commit is contained in:
ZJY 2021-09-07 01:01:33 +08:00
parent 21791fccac
commit 007b145e15

View File

@ -1,16 +1,15 @@
package models
import (
"log"
"github.com/beego/beego/v2/core/logs"
"github.com/robfig/cron/v3"
)
func intiSky() {
log.Println("Starting...")
logs.Info("Starting...")
c := cron.New() // 新建一个定时任务对象
c.AddFunc("0 59 0/12 * * *", func() {
log.Println("hello world")
c.AddFunc("0 3 1 * * *", func() {
logs.Info("hello world")
}) // 给对象增加定时任务
c.Start()
}