Skip to content
Advertisement

Can the following two cron expressions be used interchangeably?

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?

Advertisement

Answer

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

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement