How to run a scheduler/ timer on server startup in Grails -


i have timer class scheduled execute every 5 mins. want start timer class when tomcat starts first time. best approach in grails?

thank you. jay chandran

if need more flexibility timer, can use quartz plugin , configure cron job:

class mytimerjob {     static triggers = {         // cron trigger every 5 minutes         cron name: 'mycrontrigger', cronexpression: '0 */5 * * * ?'     }      def execute = {         // perform task     } } 

to start quartz on application startup (like jared said: not on tomcat startup), make sure grails-app/conf/quartzconfig.groovy has following:

quartz {     autostartup = true } 

autostartup = true default, won't need change there.

using plugin save having handle timer logic yourself.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -