Quartz ( http://grails.org/plugin/quartz ) allows you to define repetitive tasks in the same way that a CRON task will run on a single server.
You can install it in your project as follows:
grails install-plugin quartz
After installing it, you can create a new task with
grails create-job
Then you can configure it like this:
class MyJob { static triggers = { simple name: 'mySimpleTrigger', startDelay: 60000, repeatInterval: 1000 } def group = "MyGroup" def execute(){ print "Job run!" } }
If you prefer CRON formatting, you can assign a trigger in the same format:
static triggers = { cron name: 'myTrigger', cronExpression: "0 0 6 * * ?" }
However, since the grails application can be deployed on multiple servers (QA, production, deployment, load balancing ...), the quartz plugin allows a particular process to run regardless of which server it is deployed to.
One thing you should pay attention to is the synchronization of the server clock, otherwise you may encounter some strange functionality (especially if several servers use the same database).
source share