main.go 605 B

123456789101112131415161718192021222324252627282930313233
  1. package main
  2. import (
  3. "fmt"
  4. "github.com/robfig/cron"
  5. )
  6. func main() {
  7. //var lock sync.Mutex
  8. //exportFileFlag := true
  9. c := cron.New()
  10. c.AddFunc("*/10 * * * * ?", func() { fmt.Println(".. in the range 3-6am, 8-11pm") })
  11. //c.AddFunc("*/5 * * * * ?", func() {
  12. // fmt.Println(time.Now())
  13. //if exportFileFlag == true {
  14. // //lock.Lock()
  15. // //exportFileFlag = false
  16. // //lock.Unlock()
  17. // fmt.Println(time.Now())
  18. // time.Sleep(3 * time.Second)
  19. // //lock.Lock()
  20. // //exportFileFlag = true
  21. // //lock.Unlock()
  22. //} else {
  23. // fmt.Println(time.Now(), "2222222")
  24. //}
  25. //})
  26. c.Start()
  27. select {}
  28. }