Created
June 21, 2019 17:25
-
-
Save gufranmirza/3e4d2aed92cba88c17e4fe452edc2695 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c := cron.New() | |
c.AddFunc("30 * * * *", func() { | |
fmt.Println("Every hour on the half hour") | |
}) | |
c.AddFunc("30 3-6,20-23 * * *", func() { | |
fmt.Println(".. in the range 3-6am, 8-11pm") | |
}) | |
c.AddFunc("CRON_TZ=Asia/Tokyo 30 04 * * * *", func() { | |
fmt.Println("Runs at 04:30 Tokyo time every day") | |
}) | |
c.AddFunc("@hourly", func() { | |
fmt.Println("Every hour") | |
}) | |
c.AddFunc("@every 1h30m", func() { | |
fmt.Println("Every hour thirty") | |
}) | |
c.Start() | |
.. | |
// Funcs are invoked in their own goroutine, asynchronously. | |
... | |
// Funcs may also be added to a running Cron | |
c.AddFunc("@daily", func() { fmt.Println("Every day") }) | |
.. | |
// Inspect the cron job entries' next and previous run times. | |
inspect(c.Entries()) | |
.. | |
c.Stop() // Stop the scheduler (does not stop any jobs already running). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment