问题
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