Multiple 'nth' weekday of month in a single quartz cron expression

大城市里の小女人 提交于 2019-12-11 08:56:08

问题


I'm trying to write a cron expression for quartz that runs hourly everyday except every second Saturday of the month.

So, by using the '#' notation, I was trying to write the expression like:

0 0 * ? * SUN-FRI,SAT#1,SAT#3,SAT#4,SAT#5

This expression is not working properly. Also, quartz is not complaining about the cron format (quartz usually complains about cron expressions when they are wrong).

So I did some other experiments today. So, today is the third Thursday of the month, I was playing around with THU#N notation, and that's what I've found so far (I changed my expression to minute to make it easier for experimenting):

0 * * ? * SUN-FRI,SAT#1,SAT#3,SAT#4,SAT#5: not triggered 0 * * ? * THU#3: triggered 0 * * ? * THU#3,THU#4: not triggered 0 * * ? * THU#2,THU#3: triggered

I know I can simply split this into 4 additional expression but in my real scenario I have tons of expressions to change and this would increase my expression list to something 5 times longer.

In a brief: Does anyone knows how to condense these:

0 0 * ? * SUN-FRI / 0 0 * ? * SAT#1 / 0 0 * ? * SAT#3 / 0 0 * ? * SAT#4 / 0 0 * ? * SAT#5

...into a single cron expression?

Note: I'm using quartz scheduler 1.5 (I know, I know... pretty outdated)

来源:https://stackoverflow.com/questions/19438621/multiple-nth-weekday-of-month-in-a-single-quartz-cron-expression

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