I need to trigger my mail every alternate Monday and Wednesday. I am using Java Spring in my application. I have try using this cron expression 00 15 11 ? * MONDAY#1
and same for Wednesday, but it is triggering on 1 Monday and Wednesday of the month. What I want is it should trigger on Monday and Wednesday of first, third and fifth week of each month.
Can someone please help me in creating this cron expression.
All type of cron exrpession you build from website [Cron Maker]
I have one solution to meet with your requirement:
Algorithm:
1. Run cron every MON and WED day.
eg. 0 0 12 ? * MON,WED *
Start time Monday, September 7, 2015 6:10 AM Change
Next 5 scheduled dates
a. Monday, September 7, 2015 12:00 PM
b. Wednesday, September 9, 2015 12:00 PM
c. Monday, September 14, 2015 12:00 PM
d. Wednesday, September 16, 2015 12:00 PM
e. Monday, September 21, 2015 12:00 PM
2. Now pro-grammatically control on odd week. for eg in java
Calendar c = Calendar.getInstance();
if(c.get(Calendar.WEEK_OF_MONTH) % 2 != 0) {
//execute job
} else {
//not execute job just skip operation
}
if i am able to made actual cron then i will post it.