简体   繁体   中英

Spring cron job working in local but not in amazon instance

I have developed a spring boot project. It uses @EnableScheduling and @Scheduled annotations to schedule task. I have tried both ways to schedule my function.

1)

@Scheduled(initialDelayString = "${scheduler.initialDelay}", fixedDelayString = "${scheduler.fixedDelay}")

2)

@Scheduled(cron = "0 0 1 * * *")

In both ways when I run my code locally, It gets run perfectly fine. But when I deploy my code to AWS instance using auto scaling group, spring application gets start, but after that nothing is happening. I don't even see any logs or error about scheduler. Application is running but scheduler is not getting invoked. It seems very strange to me. And since its working perfectly very well in local, it is difficult to debug also.

I had a similar issue, I believe its to do with the Springboot default threadpool for scheduling. It worked for me when i altered the below setting in application.properties / yaml

spring.task.scheduling.pool.size=20

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM