Golang:每天零点定时执行操作

来源:互联网 发布:seo分析智联招聘 编辑:程序博客网 时间:2024/06/01 20:23
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()    }}
1 0
原创粉丝点击