Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quartz Cron Expression: Run Job Every 10 minutes starting NOW (immediately)

Tags:

cron

I am using Quartz Scheduler using Spring. I want to configure the same with following schedule:

Run Job Every 10 minutes starting NOW

I am using following expression for the same.

0 */10 * * * ? 

I thought * in the minutes field would make it run the first minute, but it does not do that way. It runs the first 10th minutes from now and then every 10 minutes afterwards. Can anybody please suggest me the reason for this behavior and the solution to my problem also?

like image 859
Sandeep Jindal Avatar asked Aug 09 '10 08:08

Sandeep Jindal


People also ask

How do I schedule a cron job every 10 minutes?

For example, if you have 1-10/2 in the Minutes field, it means the action will be performed every two minutes in range 1-10, same as specifying 1,3,5,7,9 . Instead of a range of values, you can also use the asterisk operator. To specify a job to be run every 20 minutes, you can use “*/20”.

What is cron expression 0 * * * *?

Meaning of cron expression 0 * * * * *? I think it means the scheduler is expected to run every seconds.

What is Quartz cron expression?

A Cron Expressions quartz. Trigger. A cron expression is a string consisting of six or seven subexpressions (fields) that describe individual details of the schedule. These fields, separated by white space, can contain any of the allowed values with various combinations of the allowed characters for that field.

How do I run a cron job after every minute?

Execute Cron Job After System Reboot. Setup and Run PHP Script As A Cron Job. Run crontab job every minute on a Linux or Unix-like system.


2 Answers

0 0/10 * 1/1 * ? * 

Please see : http://www.cronmaker.com/

like image 104
Diego Iacono Avatar answered Sep 21 '22 23:09

Diego Iacono


check the minute your at now and add them as a list to your crontrigger. if you start the trigger at minute 12 for example add

0 2,12,22,32,42,52 * * * ?  

as your cron expression

Edit:

Another solution would be to define a simpletrigger that repeats every ten minutes

SimpleTrigger trigger = new SimpleTrigger("myTrigger",                                             null,                                             new Date(),                                             null,                                             SimpleTrigger.REPEAT_INDEFINITELY,                                             10L * 60L * 1000L); 
like image 37
Nikolaus Gradwohl Avatar answered Sep 22 '22 23:09

Nikolaus Gradwohl