Spring cron expression for every after 30 minutes

d-man picture d-man · Nov 2, 2011 · Viewed 245.6k times · Source

I have following Spring job to run after every 30 minutes. Please check my cron expression, is that correct?

"0 0 0 * * 30"


Here is a full cron job definition from the related Spring configuration file:

<bean id="autoWeblogPingTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
    <property name="jobDetail" ref="jobDetailForWeblogPing"/>
    <!-- run every 35 minutes -->
    <property name="cronExpression" value="0 0 0 * * 30" />
</bean>

Answer

stacker picture stacker · Nov 2, 2011

According to the Quartz-Scheduler Tutorial It should be value="0 0/30 * * * ?"

The field order of the cronExpression is

1.Seconds

2.Minutes

3.Hours

4.Day-of-Month

5.Month

6.Day-of-Week

7.Year (optional field)

Ensure you have at least 6 parameters or you will get an error (year is optional)