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
Post a Comment