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

使用固定速率,xxl-job宕机重启后,下次执行时间乱掉 #3432

Open
fanlinzu opened this issue Apr 22, 2024 · 7 comments
Open

Comments

@fanlinzu
Copy link

Please answer some questions before submitting your issue. Thanks!

Which version of XXL-JOB do you using?

Expected behavior

Actual behavior

Steps to reproduce the behavior

Other information

@fanlinzu
Copy link
Author

默认是按重启时间和固定速率时间计算算下一次执行时间,如何考虑兼容考虑用崩溃前的最后一次执行时间和固定速率算出重启后的第一次执行时间。

@fanlinzu
Copy link
Author

问题描述:使用固定速率一小时,每隔一小时执行一次,比如第一次执行时间8:10,第二次执行时间9:10,然后在9:30的时候xxl-job重启,则该定时器的下一次执行时间会变为10:30;
需求:需要重启后的第一次执行时间为10:10

@guohui-ma
Copy link

看这个需求,和现象。是需要在某个地方保存一下这个任务上一次执行的时间。

有两个问题:

  1. 如果中间停的时间超过了你的间隔1小时呢。
  2. 为什么不适用 cron表达式 10 * * * * 来表示呢?每小时的10分执行。

@fanlinzu
Copy link
Author

cron表达式不支持考虑开始时间的周期执行。比如在未来的某个时间点开始第一次执行,然后按照固定周期循环执行。

@fanlinzu
Copy link
Author

看这个需求,和现象。是需要在某个地方保存一下这个任务上一次执行的时间。

有两个问题:

  1. 如果中间停的时间超过了你的间隔1小时呢。
  2. 为什么不适用 cron表达式 10 * * * * 来表示呢?每小时的10分执行。

若中间停的时间超过间隔一个小时,比如10:10执行时间已经错过,那重启后第一次执行时间就是11:10

@fanlinzu
Copy link
Author

看这个需求,和现象。是需要在某个地方保存一下这个任务上一次执行的时间。

有两个问题:

  1. 如果中间停的时间超过了你的间隔1小时呢。
  2. 为什么不适用 cron表达式 10 * * * * 来表示呢?每小时的10分执行。

执行周期的单位可能为分钟,从某个时间开始,按照固定周期往后推,符合时间点就执行,所以考虑到cron表达式不支持。

@AlanNiew
Copy link

AlanNiew commented May 5, 2024

可以记录一下上次执行成功的时间。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants