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?
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 .
The same effect we can reach (Quartz Spring) using more simpler construction:
0/30 * * * * ? *
The last asterisk we can omit.
0/30 * * * * ?
如果您使用的是 Spring 框架,请使用@PostConstruct
注释,然后使用@Scheduled(cron=0 0/15 * 1/1 * ?)
来触发 now,now+15min 等等。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.