I have a cron job in my spring boot application which runs periodically. On enabling job, Automatically jobs are getting triggered and it is working as expected in Windows tomcat server
But when the same code is deployed into Linux Docker environment. Jobs are not getting triggered at the scheduled time. I verified few links below. But it didn't solve my problem. Spring Boot Scheduled task not working on docker container
What is the right approach to handle this?
TestJobScheduler.class:
-------------------------
@Configuration
@EnableScheduling
public class TestJobScheduler {
@Value("${test.job.enabled}")
private boolean isTestJobEnabled;
@Scheduled(cron = "${test.cron.expression}")
public void testSchedulerJob() {
if(isTestJobEnabled) {
//Do your work
}
}
}
application.properties:
------------------------
test.job.enabled=true
test.cron.expression=0 0 6 ? * 3,5