Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cron expression for every 30 seconds in quartz scheduler?

Tags:

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?

like image 386
user1950349 Avatar asked Feb 05 '16 00:02

user1950349


People also ask

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.

What is cron expression 0 * * * *?

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

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.


2 Answers

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> 
like image 198
Ian Mc Avatar answered Sep 29 '22 00:09

Ian Mc


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.

like image 33
Jar Yit Avatar answered Sep 29 '22 02:09

Jar Yit