What is the most reliable way to schedule a job with cron scheduler is Quartz that repeats every N days starting from a specific date

我只是一个虾纸丫 提交于 2020-01-04 11:02:23

问题


In our app, we have an ability to schedule tasks and we converting this functionality to Quartz. One of the problems that I have is scheduling recurring task that should run, for example, every third day. The cron expression that I had in mind first of all is:

0 37 18 */3 * ? *

But what this will do, is execute that job on 1,4,7, etc... Which is fine, assuming that I want to start from the first day of the month. However, how to deal with this issue if I need to start from 11th? I could do something like this:

0 37 18 11/3 * ? *

But, in this case, I will always miss all the days before the 11th.

Also, when the time comes for the next month, the expectation that the day of the month will now be different (on one month the job executed on 1st, and on another it could be on 2/3), but based on the cron above it will restart on the same day (e.g. 1st).

I could, of course, count using hours, but then I will have an issue with day light saving?

What is the correct way to organize it? Or am I missing something?

UPDATE Possible solution is to use simple trigger, as per http://www.quartz-scheduler.org/documentation/quartz-2.1.x/cookbook/BiDailyTrigger. But in this case, how do I resolve DST problem?

Thanks,

来源:https://stackoverflow.com/questions/38315919/what-is-the-most-reliable-way-to-schedule-a-job-with-cron-scheduler-is-quartz-th

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!