I am using Quartz Scheduler to run my jobs. I want to run my job every thirty seconds. What will be my cron expression for that?
For every one minute, I am using below cron expression:
<cron-expression>0 0/1 * 1/1 * ? *</cron-expression>
What it will be for every thirty seconds?
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.
Meaning of cron expression 0 * * * * *? I think it means the scheduler is expected to run every 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.
The first element represents the seconds; to run at second 0 and 30 use the following:
<cron-expression>0/30 0/1 * 1/1 * ? *</cron-expression>
I hope this answer will help you. Please define the cron expression the below
0/30 * * * * ? *
And then you go this website and test Cron Expression Generator & Explainer - Quartz.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With