Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "log"
- "fmt"
- "time"
- "github.com/jakecoffman/cron"
- )
- func main() {
- //Every 5 seconds
- var c = cron.New()
- spec := "*/5 * * * * ?"
- c.AddFunc(spec, func() {
- fmt.Println("--Execute job: " + time.Now().Format("2006-01-02 15:04:05"))
- //Do what you want to do
- }, "jobRunner")
- c.Start()
- done := make(chan bool)
- go forever()
- <-done // Block forever
- }
- func forever() {
- for {
- fmt.Printf("%v+\n", time.Now())
- time.Sleep(time.Second)
- }
- }
Add Comment
Please, Sign In to add comment