赛思维服务调研
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.

37 lines
1005 B

// Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
package db
import (
cron "github.com/robfig/cron/v3"
)
/******************************************************************************
*
* @Function Name :
*-----------------------------------------------------------------------------
*
* @Description : 定时任务
*
* @Function Parameters:
*
* @Return Value :
*
* @Author : Lou Wenzhi
*
* @Date : 2021/3/8 18:00
*
******************************************************************************/
func CornTime() {
crontab := cron.New()
task := func() {
BackUp()
}
// 添加定时任务, * * * * * 是 crontab,表示每分钟执行一次
//crontab.AddFunc("*/1 * * * *", task)
crontab.AddFunc("@midnight", task)
// 启动定时器
crontab.Start()
// 定时任务是另起协程执行的,这里使用 select 简答阻塞.实际开发中需要
// 根据实际情况进行控制
select {}
}