-
-
Notifications
You must be signed in to change notification settings - Fork 340
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Job's NextRun time is inaccurate. The job has already run, but NextRun has not been updated to the next scheduled time.
Multiple Jobs run into this situation when executing simultaneously.
// create a scheduler
scheduler, err := gocron.NewScheduler()
if err != nil {
log.Fatal(err)
}
// add a job to the scheduler
job1, err := scheduler.NewJob(
gocron.DurationJob(1*time.Minute),
gocron.NewTask(func() {
log.Println("Job executed start")
time.Sleep(10 * time.Second)
log.Println("Job executed")
}),
gocron.WithName("example-job"),
gocron.WithTags("important"),
)
// add a job to the scheduler
job2, err := scheduler.NewJob(
gocron.DurationJob(2*time.Minute),
gocron.NewTask(func() {
log.Println("Job executed start")
time.Sleep(10 * time.Second)
log.Println("Job executed")
}),
gocron.WithName("example-job"),
gocron.WithTags("important"),
)
job3, err := scheduler.NewJob(
gocron.DurationJob(3*time.Minute),
gocron.NewTask(func() {
log.Println("Job executed start")
time.Sleep(10 * time.Second)
log.Println("Job executed")
}),
gocron.WithName("example-job"),
gocron.WithTags("important"),
)
job4, err := scheduler.NewJob(
gocron.DurationJob(4*time.Minute),
gocron.NewTask(func() {
log.Println("Job executed start")
time.Sleep(10 * time.Second)
log.Println("Job executed")
}),
gocron.WithName("example-job"),
gocron.WithTags("important"),
)
if err != nil {
log.Fatal(err)
}
// start the scheduler
scheduler.Start()Version
gocorn: v2.18.2
go: 1.24.10
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working