cronExpression 0 * * * *?

3.9k Views Asked by At

please tell me the meaning of "0 * * * * ?" at cronExpression.

<bean id="batchJobTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
    <property name="jobDetail" ref="batchJobDetail"/>    
    <property name="cronExpression">
        <value>0 * * * * ?</value>
    </property>
</bean>
3

There are 3 best solutions below

0
Reenactor Rob On BEST ANSWER

Second Minute Hour Day-of-month Month Day-of-week Year (optional)

0 * * * * First second of every minute of every hour of every day of every month

? Specifies no particular value. This is useful when you need to specify a value for one of the two fields Day-of-month or Day-of-week, but not the other.

0
Pierce Darragh On

It means "do this job at the beginning of every hour."

From Wikipedia:

# ┌───────────── min (0 - 59)
# │ ┌────────────── hour (0 - 23)
# │ │ ┌─────────────── day of month (1 - 31)
# │ │ │ ┌──────────────── month (1 - 12)
# │ │ │ │ ┌───────────────── day of week (0 - 6) (0 to 6 are Sunday to
# │ │ │ │ │                  Saturday, or use names; 7 is also Sunday)
# │ │ │ │ │
# │ │ │ │ │
# * * * * *  command to execute

The question mark is non-standard, and I don't think it really applies in this case. From this StackOverflow answer's reference to this webpage, we find:

? ("no specific value") - useful when you need to specify something in one of the two fields in which the character is allowed, but not the other. For example, if I want my trigger to fire on a particular day of the month (say, the 10th), but don't care what day of the week that happens to be, I would put "10" in the day-of-month field, and "?" in the day-of-week field.

1
monad.gon On

0 * * * * ?
means "every 1 minute"