How to initialize a task without first run? #176
-
For example I have the task set like: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi @hwebb you can set the individual job or the entire scheduler to wait for the first interval before running rather than running immediately. s.Every(60).Minutes().WaitForSchedule().Do(task)
or
s.WaitForScheduleAll()
s.Every(60).Minutes().Do(task) The References: |
Beta Was this translation helpful? Give feedback.
Hi @hwebb you can set the individual job or the entire scheduler to wait for the first interval before running rather than running immediately.
The
SinglettonMode()
is relevant when you have long running tasks that may run longer than the scheduled interval.References:
https://pkg.go.dev/github.com/go-co-op/gocron#Scheduler.WaitForSchedule
https://pkg.go.dev/github.com/go-co-op/gocron#Scheduler.WaitForScheduleAll
https://pkg.go.dev/github.com/go-co-op/gocron#Scheduler.SingletonMode