Search code examples
javaspring-bootcronquartz-scheduler

Can I trigger same spring batch job in different intervals during different period of time?


I have a spring batch job which is running at an interval of 1 min.
Is it possible to run the batch in following manner?

10 am to 4 pm -> Run the job at an interval of 1 minute
4 pm to 10 am -> Run the job at an interval of 1 hour

I am using XML configuration for job configuration and trigger.

<bean id="fileReadJobCronTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
    <property name="jobDetail" ref="fileReadJobDetail" />
    <property name="cronExpression" value="0 0/1 * 1/1 * ? *" />
</bean>

Solution

  • You could set up two separate triggers for that. The first from 10-16 and the 2nd from 22-04.