Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run every 25 seconds in Quartz scheduler?

I am using the Quartz Scheduling API for Java. Could you help me to run every 25 seconds using cron-expression. It's just a delay. It does not have to start always at second 0. For example, the sequence is like this: 0:00, 0:25, 0:50, 1:15, 1:40, 2:05, etc until minute 5 when the sequence begins again at second 0. Thank you.

like image 421
David Avatar asked Jun 06 '11 23:06

David


People also ask

How do I run a cron job every 5 seconds?

Cron only allows for a minimum of one minute. What you could do is write a shell script with an infinite loop that runs your task, and then sleeps for 5 seconds. That way your task would be run more or less every 5 seconds, depending on how long the task itself takes.

How do I run a cron job every second?

“cron run every second” Code Answer's*/10 * * * * * will run every 10 sec.


2 Answers

I don't think cron expression will allow you to do that, but you can use

SimpleScheduleBuilder.repeatSecondlyForever( 25 )

as 300 (5 minutes) is a multiple of 25 it will repeat automatically.

like image 154
rediVider Avatar answered Sep 18 '22 13:09

rediVider


If you want a job to trigger at a regular interval then you can use a Quartz SimpleTrigger with a repeatInterval specified.

like image 25
darrenmc Avatar answered Sep 20 '22 13:09

darrenmc