• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Cron expression with Spring Task scheduler

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
Think of how stupid the average person is. And how half of them are stupider than that. But who reads this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic