Quartzプラグインを使用してGrailsWebアプリケーションでcronジョブを設定しようとしています。私は現在、次のコードを使用して、テストジョブを1秒に1回実行しようとしています。
class TestJob {
private int counter = 0
static triggers = {
simple repeatInterval: 1000
}
def execute() {
// execute job
counter += 1
System.out.println("Testing the cron " + counter)
}
}
ただし、アプリケーションを実行すると、最初のexecute()
呼び出しの初期出力が2回しか表示されません。1回はサーバーの実行が警告される直前、もう1回は直後です。
| 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
私のクォーツジョブが正しく起動しない理由を誰かが知っていますか?単純なものではなくcronを使用したり、さまざまなパラメーターや時間間隔などを使用したりしてみました。何も違いはありません。
ありがとう