Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] When date changes to before, conJob not work #626

Closed
zishen opened this issue Dec 7, 2023 · 1 comment
Closed

[BUG] When date changes to before, conJob not work #626

zishen opened this issue Dec 7, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@zishen
Copy link

zishen commented Dec 7, 2023

Describe the bug

When I used timeCron.Every(interval).Seconds().Do() to start my cronJob. I found if the time on my machine changed before, like using date -s to set the time to an hour ago, it will not work

I found the controll code is:

func (s *Scheduler) runContinuous(job *Job) {
....
	job.setTimer(s.timer(nextRun, func() {
		if !next.dateTime.IsZero() {
			for {
				n := s.now().UnixNano() - next.dateTime.UnixNano()
				if n >= 0 {
					break
				}
				s.time.Sleep(time.Duration(n))
			}
		}
		s.runContinuous(job)
	}))
}

Version

all, but I test 1.19.0 and 1.36.0

Expected behavior

The time changes do not effect conJob.

Maybe a new interface is more suitable

Additional context

@zishen zishen added the bug Something isn't working label Dec 7, 2023
@JohnRoesler
Copy link
Contributor

Duplicate -> #438 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants