绩效考核
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

35 lines
728 B

package scheduledtask
import (
"fmt"
"time"
"github.com/robfig/cron/v3"
)
/*
定时任务模块
跟随任务一起启动,执行周期性任务操作
*/
func TimeTask() {
fmt.Println("------------准备启动定时任务--------------")
go func() {
c := cron.New(cron.WithSeconds()) //声明定时任务启动器
/*
加载任务场景
AddFunc("任务时间格式","执行的任务")
*/
c.AddFunc("0 0 8 * * *", func() {
fmt.Printf("执行定时任务------>%v\n", time.Now().UTC())
}) //每3秒执行一个任务
//启动
c.Start()
//设定全部执行后,最后关闭定时任务
defer c.Stop()
select {}
}()
fmt.Printf("定时任务启动成功!TIME:%v\n", time.Now().UTC())
}