我试图了解Java中如何写和解释Cron的表达方式。我无法理解以下两个表达式在物理意义上有何不同:
表达式1: * * * * 1/1 *? *
表达式2: * * * * * *? *
我提到 cronexpressionGenerator 的描述及其对两个表达的描述,如下:
表达1:每秒运行
表达式2:每天每秒运行
从物理意义上讲,他们俩每秒都运行。它们可以互换使用吗?
I am trying to understand how Cron expressions are written and interpreted in Java. I am unable to understand how the two expressions listed below differ in physical sense:
Expression 1: * * * 1/1 * ? *
Expression 2: * * * * * ? *
I referred to the description provided by CronExpressionGenerator and their description of the two expressions were as follows:
Expression 1: Runs every second
Expression 2: Runs every second every day
In a physical sense, they both run every second. Can they be used interchangeably?
发布评论
评论(1)
您没有发现Java的Cron。相反,您正在发现石英intepretes cron表达方式。石英比通常的Linux Cron守护程序更强大。
您正确地注意到,这两种表达式都以同一节奏发射。因此,您可以使用一个或另一个,并获得相同的结果。
此外,该文档可能有助于理解:
You are not finding out how Java does cron. Instead, you are finding out how Quartz intepretes cron expressions. Quartz is even more powerful than usual Linux cron daemons.
You noticed correctly that both expressions fire at the same rhythm. With that you may use one or the other and get the same result.
Additionally the documentation may help to understand:
http://www.quartz-scheduler.org/documentation/2.4.0-SNAPSHOT/tutorials/tutorial-lesson-06.html