Is there a way to do repetitive background tasks in Go? I\'m thinking of something like Timer.schedule(task, delay, period)
in Java. I know I can do this with
Check out this library: https://github.com/robfig/cron
Example as below:
c := cron.New()
c.AddFunc("0 30 * * * *", func() { fmt.Println("Every hour on the half hour") })
c.AddFunc("@hourly", func() { fmt.Println("Every hour") })
c.AddFunc("@every 1h30m", func() { fmt.Println("Every hour thirty") })
c.Start()