Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cron expression with Spring Task scheduler

 
Nitesh Patel
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
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,

or

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 somebody please guide me ?

Thanks & Regards,
Nitesh
 
Manish Sridharan
Ranch Hand
Posts: 65
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nitesh,

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.

Thanks,
 
Nitesh Patel
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Manish,
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.

Thanks,
Nitesh
 
Manish Sridharan
Ranch Hand
Posts: 65
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.


Thanks,
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic