main.go 518 B

123456789101112131415161718192021222324
  1. package main
  2. import (
  3. "abnormalReturned/config"
  4. "fmt"
  5. "github.com/robfig/cron"
  6. "time"
  7. )
  8. func main() {
  9. //一天跑两次数据
  10. c := cron.New()
  11. // 每天早上 8:00 和晚上 20:00 执行
  12. c.AddFunc(config.DbConf.Cron, func() {
  13. fmt.Println("早上执行任务:", time.Now())
  14. })
  15. }
  16. func returnHandle() {
  17. startTime := time.Now().AddDate(0, 0, -14).Format(time.DateTime)
  18. if time.Now().Unix() > 1746028800 {
  19. startTime = time.Now().AddDate(0, -1, 0).Format(time.DateTime)
  20. }
  21. config.CTiDbMysql.SelectBySql()
  22. }