123456789101112131415161718192021 |
- package TimeTask
- import (
- "PublishCode/logs"
- "PublishCode/models"
- "fmt"
- "github.com/robfig/cron/v3"
- )
- func TimeTaskGo() {
- logs.Println("==========定时任务开始==========")
- crontab := cron.New(cron.WithSeconds())
- _, err := crontab.AddFunc("0 0 0 * * *", models.PublishCode_Indexes)
- if err != nil {
- fmt.Printf("err: %v\n", err)
- logs.Println("Cron [models.PublishCode_Indexes] OK!")
- }
- crontab.Start() // 开始任务
- }
|