Cron expression for the second-last day of the week of the month
I want to run the second on the last day of the week of the month.
Typically, this is the last Friday of the month (ex: 30/06/2017)
0 0 0 ? * FRIL
And I want the second to continue (ex: 23/06/2017)
0 0 0 ? * FRIL-1
But this syntax returns the same result as before (using Quartz scheduler and cronmaker )
The second and last day of the week of the month can appear on either the 3rd or 4th week of the month. So:
either : 0 0 0 ? * FRI#3
or : 0 0 0 ? * FRI#4
Do you have any tips?
source to share
I don't think you can express this using cron syntax.
I can think of some problems:
-
You can schedule your work every Friday and have some work logic to check if it is actually second to last before continuing.
-
Another option is to create a dummy cron trigger for last Friday, get the "next fire time", subtract 7 days from that date, and create an actual trigger using that exact date - but you would have to do this every week (either by pre-planning multiple triggers, or by reassigning your work after each run).
source to share