I am using spring task scheduler to execute couple of task at particular time (like every day at 3:00 AM, every Monday at 10:00PM etc). For one of task I have specific requirement to execute it first Monday of every month at 3:00 AM. I search some forums and tried below expression but none of them work,
Above expression throws as below,
I have read the documentation of Spring but it does not mention about MON#1 format but some forums does.
I have also review the Spring source (for CronSequenceGenerator) but could not find any code to handle this expression (which interpret as First Monday of every month).
Can you try with this string "0 0 3 0 * 2" . This just might work. Also you can refer to this URL for setting up a cron expression.
Joined: Mar 16, 2008
Thanks for the reply. I figure it out using "0 1 0 1-7 * MON" expression (which ensure it only run for 1st 7 days of month - first week of month). But definitely I will try your expression as well.
Joined: Jul 19, 2005
Apologies the String should be It will make it run only once in a month. This works in cron job, not sure it works in spring task or not. you need to test it to confirm it.