I have a spring application that uses quartz cron trigger. I have given the following for frequency 0 0/20 * * * ?…..once every 20 min. But i want the first one to run immediately. Right now, when I start the application, it runs after 20 min. I was hoping it would run asap and then after 20 min.
Thanks in advance.
You don’t need CRON expression (and Quartz at all!) to run given code every 20 minutes. Just use fixed rate (Spring built-in):
That’s it! By default first invocation happens immediately, second after 20 minutes. Since Spring 3.2 you can even say
initialDelay=10000to run for the first time after exactly 10 seconds.If you really want to use Quartz, check out
SimpleTrigger.