沈阳玫苑物业管理后端
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.

36 lines
1005 B

4 years ago
  1. // Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
  2. package db
  3. import (
  4. cron "github.com/robfig/cron/v3"
  5. )
  6. /******************************************************************************
  7. *
  8. * @Function Name :
  9. *-----------------------------------------------------------------------------
  10. *
  11. * @Description : 定时任务
  12. *
  13. * @Function Parameters:
  14. *
  15. * @Return Value :
  16. *
  17. * @Author : Lou Wenzhi
  18. *
  19. * @Date : 2021/3/8 18:00
  20. *
  21. ******************************************************************************/
  22. func CornTime() {
  23. crontab := cron.New()
  24. task := func() {
  25. BackUp()
  26. }
  27. // 添加定时任务, * * * * * 是 crontab,表示每分钟执行一次
  28. //crontab.AddFunc("*/1 * * * *", task)
  29. crontab.AddFunc("@midnight", task)
  30. // 启动定时器
  31. crontab.Start()
  32. // 定时任务是另起协程执行的,这里使用 select 简答阻塞.实际开发中需要
  33. // 根据实际情况进行控制
  34. select {}
  35. }