Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quartz job for Grails only fires once

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

like image 335
Mike Caputo Avatar asked Jul 13 '12 18:07

Mike Caputo


1 Answers

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.

like image 123
Chris Avatar answered Oct 02 '22 17:10

Chris