tags:

views:

83

answers:

2

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

+5  A: 

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.

John Wagenleitner
I've used Quartz on J2EE apps, but I'm new to Grails so I didn't know there was a plugin. Thanks!
byamabe
A: 

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.

Jon