Menu

Spring @Scheduled job stopped? Know when it does
📰

Spring @Scheduled job stopped? Know when it does

DEV Community: java·Nilail·about 15 hours ago
#5r5tk9F0
#devtojava#devto#dev#scheduled#spring
Reading 0:00
15s threshold

A Spring Boot @Scheduled job that stops without an error is usually waiting behind another job stuck on the scheduler’s single thread; scheduling switched off, a cron set to - or a missing instance do the same. None of them logs anything, and the health check stays UP . Here is how to confirm each cause, fix it, and be alerted the day it starts.

Does an exception stop a @Scheduled job?

Start with what does not stop a job. Take a method that always fails:

@Scheduled ( fixedRate = 1000 ) void failing ( ) { throw new IllegalStateException ( "boom" ) ; }

Enter fullscreen mode

Exit fullscreen mode

Run on Spring Boot 3.5.7, it logs this every second, and keeps being called:

ERROR 748 --- [ scheduling-1] o.s.s.s.TaskUtils$LoggingErrorHandler : Unexpected error occurred in scheduled task java.lang.IllegalStateException: boom

Enter fullscreen mode

Exit fullscreen mode

Spring logs the exception of a repeating task and schedules the next run anyway.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.