I am trying to setup a cron job in my Grails web application using the Quartz plugin. I am currently simply trying to get a test job to execute once every second using the following code:
class TestJob {
private int counter = 0
static triggers = {
simple repeatInterval: 1000
}
def execute() {
// execute job
counter += 1
System.out.println("Testing the cron " + counter)
}
}
However, when I run the application I only see the initial output of the first execute()
call twice: once immediately before I am alerted that the server is running, and once immediately after.
| Loading Grails 2.1.0
| Configuring classpath.
| Environment set to development.....
| Packaging Grails application.....
| Compiling 1 source files.....
| Running Grails application
Testing the cron 1
| Server running. Browse to http://localhost:8080/QuartzTest
Testing the cron 1
Does anyone know why my Quartz job might not be firing correctly? I have tried using a cron instead of simple as well as using varying parameters, time intervals, etc. Nothing has made a difference.
Thanks
I think I had similar issues. You are not allowed to use System.out.println
from within a quartz-job. Try to use log.error
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With