Quartz Expression that runs every minute only once
Asked Answered
C

4

5

I have this quartz cron expression: exp = "0 * * ? * *" that runs every minute. I use this expression as a trigger to call a HTTP POST method every minute. The problem is that it calls the post method multiple times. I need an expression that will execute one time in a minute. Any suggestion how to do that?

Catty answered 16/8, 2018 at 15:30 Comment(0)
B
19

This works with Quartz.

Every 1 minute, exactly at the start of a minute - 0 0/1 * * * ?

Blighter answered 27/8, 2018 at 19:12 Comment(0)
C
3

How about a simple schedule trigger instead?

trigger = newTrigger()
    .withIdentity("trigger7", "group1")
    .withSchedule(simpleSchedule()
        .withIntervalInMinutes(1) )
    .build();

Source : Quartz tutorial-lesson-05 / Build a trigger that will fire now, then repeat every five minutes

Communalism answered 17/8, 2018 at 14:18 Comment(0)
C
1

It may happen because request lasts longer than 1 min. You can simply annotate class implemented with Jobs with @DisallowConcurrentExecution, which disallow your job execute multiple times in exact time. You can check example .

Cointreau answered 23/10, 2018 at 7:22 Comment(0)
S
-1

use this expression :

"* * * * *"
i.e 5 asteriks
try using that. use this link for reference :
https://crontab.guru/every-1-minute

Shumpert answered 16/8, 2018 at 15:58 Comment(1)
It doesen't work. The expression is not valid. The expression should be a quartz one.Catty

© 2022 - 2024 — McMap. All rights reserved.