Closed ssongliu closed 8 months ago
Hello @robfig.
Thank you very much for providing such excellent code! but I have encountered an issue while using it.
Suppose the current time is 2023-11-02 09:00:00, and I've enabled a scheduled task to run at 10:30 every day. (Based on the code and the current time, a 1-hour timer will be activated.)
for { // Determine the next entry to run. sort.Sort(byTime(c.entries)) var timer *time.Timer if len(c.entries) == 0 || c.entries[0].Next.IsZero() { // If there are no entries yet, just sleep - it still handles new entries // and stop requests. timer = time.NewTimer(100000 * time.Hour) } else { timer = time.NewTimer(c.entries[0].Next.Sub(now)) } ...
Change the system time to 2023-11-05 06:00:00. (When the timer runs one hour later, it starts execution, and at that time, the system time is 2023-11-05 07:00:00.) At this point, the execution condition only relies on the following code:
if e.Next.After(now) || e.Next.IsZero() { break }
It will pass this condition and execute the scheduled task without matching the originally set execution time of 10:30.
Thanks.
系统时间都改了,这种表现是正常的啊,我觉得没啥问题
Hello @robfig.
Thank you very much for providing such excellent code! but I have encountered an issue while using it.
Suppose the current time is 2023-11-02 09:00:00, and I've enabled a scheduled task to run at 10:30 every day. (Based on the code and the current time, a 1-hour timer will be activated.)
for { // Determine the next entry to run. sort.Sort(byTime(c.entries)) var timer *time.Timer if len(c.entries) == 0 || c.entries[0].Next.IsZero() { // If there are no entries yet, just sleep - it still handles new entries // and stop requests. timer = time.NewTimer(100000 * time.Hour) } else { timer = time.NewTimer(c.entries[0].Next.Sub(now)) } ...
Change the system time to 2023-11-05 06:00:00. (When the timer runs one hour later, it starts execution, and at that time, the system time is 2023-11-05 07:00:00.) At this point, the execution condition only relies on the following code:
if e.Next.After(now) || e.Next.IsZero() { break }
It will pass this condition and execute the scheduled task without matching the originally set execution time of 10:30.
Thanks.
This doesn't seem to be a problem for this library to deal with. The issues should be closed.
Hello @robfig.
Thank you very much for providing such excellent code! but I have encountered an issue while using it.
Suppose the current time is 2023-11-02 09:00:00, and I've enabled a scheduled task to run at 10:30 every day. (Based on the code and the current time, a 1-hour timer will be activated.)
Change the system time to 2023-11-05 06:00:00. (When the timer runs one hour later, it starts execution, and at that time, the system time is 2023-11-05 07:00:00.) At this point, the execution condition only relies on the following code:
It will pass this condition and execute the scheduled task without matching the originally set execution time of 10:30.
Thanks.