Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Periodic Task in Grails

Tags:

grails

I want to run a periodic task within a Grails application. Can anyone recommend a best practice for doing this?

like image 422
byamabe Avatar asked Dec 10 '25 15:12

byamabe


2 Answers

My recommendation would be the Quartz Plugin, here's a summary of the plugin from the site:

Quartz plugin allows your Grails application to schedule jobs to be executed using a specified interval or cron expression. The underlying system uses the Quartz Enterprise Job Scheduler configured via Spring, but is made simpler by the coding by convention paradigm.

like image 63
John Wagenleitner Avatar answered Dec 12 '25 09:12

John Wagenleitner


A simple way to do this based on the core JDK libraries is via the TimerTask, that should allow you to setup a recurring event:

http://java.sun.com/javase/6/docs/api/java/util/TimerTask.html

There's a good IBM article here on using it for this purpose:

http://www.ibm.com/developerworks/java/library/j-schedule.html

If you want something more complex in terms of control then look at Quartz or Enterprise Quartz.

like image 32
Jon Avatar answered Dec 12 '25 10:12

Jon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!