import (
"time"
"fmt"
)
//定时结算Boottime表数据
func BoottimeTimingSettlement() {
for {
now := time.Now()
// 计算下一个零点
next := now.Add(time.Hour * 24)
next = time.Date(next.Year(), next.Month(), next.Day(), 0, 0, 0, 0, next.Location())
t := time.NewTimer(next.Sub(now))
<-t.C
Printf("定时结算Boottime表数据,结算完成: %v\n",time.Now())
//以下为定时执行的操作
BoottimeSettlement()
}
}
Golang:每天零点定时执行操作
最新推荐文章于 2024-08-16 17:05:05 发布