[英]cron expression for every 30 seconds in quartz scheduler?
I am using Quartz Scheduler to run my jobs.我正在使用 Quartz Scheduler 来运行我的作业。 I want to run my job every thirty seconds.
我想每三十秒运行一次我的工作。 What will be my cron expression for that?
我的 cron 表达式是什么?
For every one minute, I am using below cron expression:每一分钟,我都使用以下 cron 表达式:
<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:
要在 0 秒和 30 秒运行,请使用以下命令:
<cron-expression>0/30 0/1 * 1/1 * ? *</cron-expression>
I hope this answer will help you.我希望这个答案对你有帮助。 Please define the cron expression the below
请定义下面的 cron 表达式
0/30 * * * * ? *
And then you go this website and test Cron Expression Generator & Explainer - Quartz .然后你去这个网站并测试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 * * * * ?
Quartz scheduler cron trigger documentation 2.x Quartz scheduler cron trigger 文档 2.x
如果您使用的是 Spring 框架,请使用@PostConstruct
注释,然后使用@Scheduled(cron=0 0/15 * 1/1 * ?)
来触发 now,now+15min 等等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.