Add Jitter
Add some Jitter to the Entry's scheduled time. The actual jitter used will be randomly chosen within the range [0, Jitter]. The jitter will always be converted to a positive duration. Plus:
-
AddFuncWithJitteradds a func to the Cron to be run on the given schedule. The spec is parsed using the time zone of this Cron instance as the default. An opaque ID is returned that can be used to later remove it. -
AddJobWithJitteradds a Job to the Cron to be run on the given schedule with a specified amount of jitter for each invocation. The spec is parsed using the time zone of this Cron instance as the default. An opaque ID is returned that can be used to later remove it. -
ScheduleWithJitteradds a Job to the Cron to be run on the given schedule with a specified amount of jitter for each invocation. The job is wrapped with the configured Chain. -
WithTimeCallbackuses the provided time function callback for getting the current time.
@mohsenpashna I made a fork that addresses almost all issues of this repo. https://github.com/alaingilbert/cron
This is how you could do what you want to do ->
// Jitter adds some random delay before running the job
_, _ = c.AddJob("*/5 * * * *", cron.WithJitter(time.Minute, func() {
fmt.Println("Runs every 5min, but wait 0-1 minute before starting")
}))