Reputation: 563
I explored and found that in quartz cron expressions :
sec min hour day_of_month month day_of_week year,
we can provide either day_of_month
or day_of_week
, but not both of them, as it's not implemented yet.
I want to run the scheduler after every two weeks
and on MONDAY, THURSDAY, FRIDAY at 12 pm , then how can I achieve this.
providing following cron expression won't work:
* * 12 1/14 * MON, THU, FRI *
because we can't provide both day_of_week and day_of_month
.
So, please let me know if there exists any other way of doing it, some other library etc. And I do not want to handle it in business logic rather simply using the cronexpression
should suffice my needs.
Upvotes: 3
Views: 10916
Reputation: 2115
As far as I understood, you need such a query:
0 0 12 1-7,14-21 * MON,THU,FRI *
which means, that you will run your program from first to seven day of month, from fourteen to twenty one day of month but only if day of week is Monday, Thursday or Friday.
So the next occurence time will be:
2016-12-19T12:00:00+01:00
2017-01-02T12:00:00+01:00
2017-01-05T12:00:00+01:00
2017-01-06T12:00:00+01:00
....
the other question is, if the evaluator can handle such query correctly, you have to check it.
Upvotes: 0
Reputation: 6782
try this site https://crontab.guru/ it may help you..
or http://www.corntab.com/?c=0_12___1,4,5
and for your question this will be that expression
0 12 * * 1,4,5
and for your understanding :
+---------------- minute (0 - 59)
| +------------- hour (0 - 23)
| | +---------- day of month (1 - 31)
| | | +------- month (1 - 12)
| | | | +---- day of week (0 - 7) (Sunday=0 or 7)
| | | | |
0 12 * * 1,4,5 command to be executed
Output:
“At 12:00 on Monday, Thursday, and Friday.”
next at 2016-12-15 12:00:00
then at 2016-12-16 12:00:00
then at 2016-12-19 12:00:00
then at 2016-12-22 12:00:00
then at 2016-12-23 12:00:00
.....
Upvotes: 0