<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nilail</title>
    <description>The latest articles on DEV Community by Nilail (@nilail_befc3a8ea2b9130eca).</description>
    <link>https://dev.to/nilail_befc3a8ea2b9130eca</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F99mvlsfu5tfj9m7ku25d.png</url>
      <title>DEV Community: Nilail</title>
      <link>https://dev.to/nilail_befc3a8ea2b9130eca</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nilail_befc3a8ea2b9130eca"/>
    <language>en</language>
    <item>
      <title>Quartz job not firing? Causes and how to check</title>
      <dc:creator>Nilail</dc:creator>
      <pubDate>Tue, 17 Nov 2026 17:22:05 +0000</pubDate>
      <link>https://dev.to/silencewatch/quartz-job-not-firing-causes-and-how-to-check-2ede</link>
      <guid>https://dev.to/silencewatch/quartz-job-not-firing-causes-and-how-to-check-2ede</guid>
      <description>&lt;p&gt;A Quartz job that does not fire is usually waiting for a free worker thread, skipped by its misfire instruction, running on an old schedule kept in the database, or attached to a trigger in the &lt;code&gt;ERROR&lt;/code&gt; state; sometimes the scheduler never started. Quartz knows which: the trigger’s state and its next fire time tell you. Here is how to read them, fix each cause, and be alerted the next time a job goes quiet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why is my Quartz job not firing?
&lt;/h2&gt;

&lt;p&gt;Quartz does not run a job; it fires a &lt;strong&gt;trigger&lt;/strong&gt;, and the trigger runs the job. When a job goes quiet, the trigger is where the answer is. Five causes cover most cases.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. The scheduler never started
&lt;/h3&gt;

&lt;p&gt;In Spring Boot, the scheduler starts with the application unless &lt;code&gt;spring.quartz.auto-startup&lt;/code&gt; is &lt;code&gt;false&lt;/code&gt;. Outside Spring, nothing fires until something calls &lt;code&gt;scheduler.start()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To confirm, look for Quartz’s own line at startup, &lt;code&gt;Scheduler quartzScheduler_$_NON_CLUSTERED started.&lt;/code&gt; with Spring Boot’s default name. If it is not in the log, no trigger will fire.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Every worker thread is busy
&lt;/h3&gt;

&lt;p&gt;Quartz runs jobs on a fixed pool of worker threads. Spring’s &lt;code&gt;SchedulerFactoryBean&lt;/code&gt;, which Spring Boot uses, gives it &lt;strong&gt;10 threads&lt;/strong&gt; by default. If long jobs hold all of them, the next trigger waits. Once it has waited longer than the misfire threshold (&lt;code&gt;org.quartz.jobStore.misfireThreshold&lt;/code&gt;: 60 seconds by default with a JDBC job store, 5 seconds with the in-memory one under Spring), Quartz stops waiting and applies the trigger’s &lt;strong&gt;misfire instruction&lt;/strong&gt; instead.&lt;/p&gt;

&lt;p&gt;To confirm, take a thread dump (&lt;code&gt;jstack &amp;lt;pid&amp;gt;&lt;/code&gt;): the worker threads (named after the scheduler, &lt;code&gt;…_Worker-1&lt;/code&gt; to &lt;code&gt;…_Worker-10&lt;/code&gt;) are all inside your jobs. With a JDBC job store, Quartz also logs &lt;code&gt;Handling 1 trigger(s) that missed their scheduled fire-time.&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. The misfire instruction skips the run
&lt;/h3&gt;

&lt;p&gt;What happens to a missed run depends on the trigger. A &lt;code&gt;CronTrigger&lt;/code&gt; uses the smart policy by default, which for a cron means &lt;strong&gt;fire once now&lt;/strong&gt;: several missed runs collapse into one late run. A trigger built with &lt;code&gt;withMisfireHandlingInstructionDoNothing()&lt;/code&gt; does the opposite: the missed run is &lt;strong&gt;dropped&lt;/strong&gt;, and the trigger waits for its next scheduled time. No log line names the job.&lt;/p&gt;

&lt;p&gt;To confirm, read the trigger’s definition in your code, or the &lt;code&gt;MISFIRE_INSTR&lt;/code&gt; column of &lt;code&gt;QRTZ_TRIGGERS&lt;/code&gt; with a JDBC job store.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. The schedule in the database is not the one in your code
&lt;/h3&gt;

&lt;p&gt;With &lt;code&gt;spring.quartz.job-store-type: jdbc&lt;/code&gt;, jobs and triggers live in the database and survive restarts. Spring Boot’s &lt;code&gt;spring.quartz.overwrite-existing-jobs&lt;/code&gt; is &lt;strong&gt;&lt;code&gt;false&lt;/code&gt; by default&lt;/strong&gt;, so a trigger that already exists in the database is &lt;strong&gt;not updated&lt;/strong&gt; at startup. You change the cron in the code, deploy, and Quartz keeps firing on the old one.&lt;/p&gt;

&lt;p&gt;To confirm, compare the code with the database:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;trigger_group&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;trigger_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;trigger_state&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;next_fire_time&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;qrtz_triggers&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;trigger_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cron_expression&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;qrtz_cron_triggers&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;next_fire_time&lt;/code&gt; is in milliseconds since the epoch. A date far in the past, or a cron that is not the one you wrote, is the answer.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. The trigger is paused, blocked or in ERROR
&lt;/h3&gt;

&lt;p&gt;A trigger has a state: &lt;code&gt;NORMAL&lt;/code&gt;, &lt;code&gt;PAUSED&lt;/code&gt;, &lt;code&gt;BLOCKED&lt;/code&gt;, &lt;code&gt;ERROR&lt;/code&gt; or &lt;code&gt;COMPLETE&lt;/code&gt;. Only &lt;code&gt;NORMAL&lt;/code&gt; fires on time.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;ERROR&lt;/code&gt;&lt;/strong&gt;: with a JDBC job store, Quartz sets it when it cannot load the job, because the stored job names a class this application cannot load: a job scheduled at runtime whose class was later renamed or moved, or a job of another application that shares the same Quartz tables and scheduler name. It logs &lt;code&gt;Error retrieving job, setting trigger state to ERROR.&lt;/code&gt; once, and the trigger never fires again on its own.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;PAUSED&lt;/code&gt;&lt;/strong&gt;: someone, or some code, called &lt;code&gt;pauseTrigger&lt;/code&gt; or &lt;code&gt;pauseJob&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;BLOCKED&lt;/code&gt;&lt;/strong&gt;: the job is annotated &lt;code&gt;@DisallowConcurrentExecution&lt;/code&gt; and its previous run has not finished. If that run is stuck, the trigger stays blocked.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To confirm, ask Quartz. With Spring Boot Actuator, &lt;code&gt;/actuator/quartz/triggers/&amp;lt;group&amp;gt;/&amp;lt;name&amp;gt;&lt;/code&gt; returns the trigger’s &lt;code&gt;state&lt;/code&gt;, &lt;code&gt;previousFireTime&lt;/code&gt; and &lt;code&gt;nextFireTime&lt;/code&gt; (expose it with &lt;code&gt;management.endpoints.web.exposure.include: health,quartz&lt;/code&gt;). Without Actuator, &lt;code&gt;scheduler.getTriggerState(triggerKey)&lt;/code&gt; gives the same answer; the &lt;code&gt;trigger_state&lt;/code&gt; column above holds Quartz’s internal state instead: &lt;code&gt;WAITING&lt;/code&gt; or &lt;code&gt;ACQUIRED&lt;/code&gt; for a trigger that will fire, then &lt;code&gt;PAUSED&lt;/code&gt;, &lt;code&gt;BLOCKED&lt;/code&gt; or &lt;code&gt;ERROR&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why logs and health checks miss it
&lt;/h2&gt;

&lt;p&gt;None of these causes raises an alarm by itself. Most write nothing, because the job does not run. The misfire line is logged at INFO, and the &lt;code&gt;ERROR&lt;/code&gt; line is logged once, when the trigger breaks, then never again. The health endpoint says &lt;code&gt;UP&lt;/code&gt;, because the application is fine; Spring Boot has no health indicator for Quartz.&lt;/p&gt;

&lt;p&gt;The only reliable signal is the &lt;strong&gt;missing run&lt;/strong&gt; itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to be alerted when a Quartz job stops firing
&lt;/h2&gt;

&lt;p&gt;Have each job report its runs to a service that knows the schedule and alerts when a run does not arrive: a &lt;a href="https://silencewatch.com/dead-mans-switch/" rel="noopener noreferrer"&gt;dead man’s switch&lt;/a&gt;. It catches every cause that stops the runs (1, 3 and 5), and a delay (cause 2) longer than its grace period, without needing to know which one happened. Cause 4 is different: the job still runs, on the old schedule. To catch it, compare the stored cron with your code after any deploy that changes it (the query above).&lt;/p&gt;

&lt;h2&gt;
  
  
  How to fix a Quartz job that does not fire
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Not started&lt;/strong&gt;: remove &lt;code&gt;spring.quartz.auto-startup: false&lt;/code&gt;, or call &lt;code&gt;scheduler.start()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Busy threads&lt;/strong&gt;: put a timeout on every outgoing call a job makes, and raise the pool if the jobs really need to overlap: &lt;code&gt;spring.quartz.properties.org.quartz.threadPool.threadCount: 20&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Skipped misfires&lt;/strong&gt;: choose the misfire instruction on purpose. Keep the default when one late run is better than none; use &lt;code&gt;withMisfireHandlingInstructionDoNothing()&lt;/code&gt; only when a late run would do harm.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Old schedule in the database&lt;/strong&gt;: set &lt;code&gt;spring.quartz.overwrite-existing-jobs: true&lt;/code&gt;, so the triggers declared in your code replace the stored ones at startup, or reschedule the trigger yourself with &lt;code&gt;scheduler.rescheduleJob(...)&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trigger in &lt;code&gt;ERROR&lt;/code&gt;&lt;/strong&gt;: make the stored job loadable first: put the class back under its old name, or replace the stored job with &lt;code&gt;scheduler.addJob(jobDetail, true, true)&lt;/code&gt; (the last &lt;code&gt;true&lt;/code&gt; lets Quartz store a non-durable job; for jobs declared as beans, one start with &lt;code&gt;spring.quartz.overwrite-existing-jobs: true&lt;/code&gt; does it). Then call &lt;code&gt;scheduler.resetTriggerFromErrorState(triggerKey)&lt;/code&gt;, available since Quartz 2.3.0, or reschedule the trigger. A reset alone sends the trigger back to &lt;code&gt;ERROR&lt;/code&gt; at its next fire time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Blocked by a stuck run&lt;/strong&gt;: find the stuck run with a thread dump and give its outgoing calls a timeout; until it returns, a &lt;code&gt;@DisallowConcurrentExecution&lt;/code&gt; job will not run again.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Why is my Quartz job not executing?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Most often its trigger is waiting for a free worker thread, its missed run was dropped by the misfire instruction, the trigger stored in the database still has an old schedule, the trigger is paused, blocked or in the &lt;code&gt;ERROR&lt;/code&gt; state, or the scheduler never started. The trigger’s state and next fire time tell you which.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a misfire in Quartz?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A misfire is a run that could not start on time, because no worker thread was free or the scheduler was down, and has waited longer than the misfire threshold. Quartz then applies the trigger’s misfire instruction: run once now, or skip to the next scheduled time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why did changing the cron expression not change my Quartz job?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With a JDBC job store, Spring Boot does not overwrite triggers that already exist in the database unless &lt;code&gt;spring.quartz.overwrite-existing-jobs&lt;/code&gt; is &lt;code&gt;true&lt;/code&gt;. The old trigger keeps its old schedule.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I fix a Quartz trigger in the ERROR state?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Make the stored job loadable again, usually by restoring a renamed or moved class or replacing the stored job with &lt;code&gt;scheduler.addJob(jobDetail, true, true)&lt;/code&gt;, then call &lt;code&gt;scheduler.resetTriggerFromErrorState&lt;/code&gt; with the trigger key. A reset alone puts it back in &lt;code&gt;ERROR&lt;/code&gt; at its next fire time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How can I be alerted when a Quartz job stops running?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Have each run report to a service that expects it on the job’s schedule and alerts when it is missing, a dead man’s switch.&lt;/p&gt;

&lt;h2&gt;
  
  
  See also
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://silencewatch.com/blog/spring-scheduled-job-stops/" rel="noopener noreferrer"&gt;Spring &lt;code&gt;@Scheduled&lt;/code&gt; job stopped&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://silencewatch.com/blog/quartz-job-not-firing/" rel="noopener noreferrer"&gt;SilenceWatch blog&lt;/a&gt;. This article was written with the help of AI and checked against the sources before publishing.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>springboot</category>
      <category>monitoring</category>
      <category>devops</category>
    </item>
    <item>
      <title>Spring @Scheduled job stopped? Know when it does</title>
      <dc:creator>Nilail</dc:creator>
      <pubDate>Tue, 17 Nov 2026 17:20:48 +0000</pubDate>
      <link>https://dev.to/silencewatch/spring-scheduled-job-stopped-know-when-it-does-1po7</link>
      <guid>https://dev.to/silencewatch/spring-scheduled-job-stopped-know-when-it-does-1po7</guid>
      <description>&lt;p&gt;A Spring Boot &lt;code&gt;@Scheduled&lt;/code&gt; 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 &lt;code&gt;-&lt;/code&gt; or a missing instance do the same. None of them logs anything, and the health check stays &lt;code&gt;UP&lt;/code&gt;. Here is how to confirm each cause, fix it, and be alerted the day it starts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Does an exception stop a &lt;code&gt;@Scheduled&lt;/code&gt; job?
&lt;/h2&gt;

&lt;p&gt;Start with what does &lt;em&gt;not&lt;/em&gt; stop a job. Take a method that always fails:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Scheduled&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fixedRate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;failing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;IllegalStateException&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"boom"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run on Spring Boot 3.5.7, it logs this every second, and keeps being called:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ERROR 748 --- [   scheduling-1] o.s.s.s.TaskUtils$LoggingErrorHandler : Unexpected error occurred in scheduled task
java.lang.IllegalStateException: boom
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Spring logs the exception of a repeating task and schedules the next run anyway. That is useful, and it is also why a failing job can go on failing for weeks: the error is in a log, and nobody reads that log until something downstream breaks.&lt;/p&gt;

&lt;p&gt;The jobs that really go quiet are the next ones.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why a &lt;code&gt;@Scheduled&lt;/code&gt; job stops without an error
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. One stuck job freezes all the others
&lt;/h3&gt;

&lt;p&gt;By default, Spring Boot runs every &lt;code&gt;@Scheduled&lt;/code&gt; method on &lt;strong&gt;a single thread&lt;/strong&gt; (&lt;code&gt;spring.task.scheduling.pool.size&lt;/code&gt; is &lt;code&gt;1&lt;/code&gt;). If one of them never returns, because it waits on a socket without a timeout, a lock or a queue, &lt;strong&gt;none&lt;/strong&gt; of the others runs again.&lt;/p&gt;

&lt;p&gt;I reproduced it with three jobs: a heartbeat every second, the failing job above, and one that blocks forever from the fourth second:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;17:39:40.449  heartbeat job ran
17:39:41.449  heartbeat job ran
17:39:41.451  stuck job starts and never returns
              (nothing after this line: no error, no warning, the process keeps running)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The heartbeat job and the failing job both stop at that moment. The application is alive, so a liveness probe and a health check are happy.&lt;/p&gt;

&lt;p&gt;To confirm, take a thread dump (&lt;code&gt;jstack &amp;lt;pid&amp;gt;&lt;/code&gt; or Actuator’s &lt;code&gt;threaddump&lt;/code&gt; endpoint; only &lt;code&gt;health&lt;/code&gt; is exposed over HTTP by default, so add &lt;code&gt;management.endpoints.web.exposure.include: scheduledtasks,threaddump,env&lt;/code&gt; for the checks below): &lt;code&gt;scheduling-1&lt;/code&gt; sits in the stuck method, in a socket read or waiting on a lock.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Scheduling is switched off
&lt;/h3&gt;

&lt;p&gt;Without &lt;code&gt;@EnableScheduling&lt;/code&gt;, a &lt;code&gt;@Scheduled&lt;/code&gt; annotation is only an annotation: no error, no run. It is easy to lose in a refactoring of the configuration classes, and the application still starts and serves requests. To confirm, look at Actuator’s &lt;code&gt;scheduledtasks&lt;/code&gt; endpoint: it lists no task.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. The schedule is disabled by a property
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;@Scheduled(cron = "${report.cron}")&lt;/code&gt; accepts the special value &lt;code&gt;-&lt;/code&gt;, which Spring documents as a disabled trigger, meant to switch a job off from the outside. A &lt;code&gt;-&lt;/code&gt; left in one environment’s configuration (copied from a test profile, say), and that job is never scheduled there. Any other invalid value fails at startup instead. To confirm, note that the task is missing from &lt;code&gt;scheduledtasks&lt;/code&gt;, and look for &lt;code&gt;report.cron&lt;/code&gt; in that environment’s configuration. &lt;code&gt;/actuator/env/report.cron&lt;/code&gt; shows where the property comes from, but since Spring Boot 3 its value is masked unless &lt;code&gt;management.endpoint.env.show-values&lt;/code&gt; is set.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. The application is not running where you think
&lt;/h3&gt;

&lt;p&gt;A job that runs in a single instance dies with it: a scaled-down deployment, a crash loop, an instance that was never started in that environment. Nothing in the application can report it, because the application is gone. To confirm, check the replica count and restarts (&lt;code&gt;kubectl get deploy,pods&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;All four have the same signature: &lt;strong&gt;nothing happens, so nothing is written&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why logs and health checks miss it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Logs.&lt;/strong&gt; There is no line to search for. You can alert on an error; you cannot alert on a line that is not there.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Health checks and liveness probes.&lt;/strong&gt; They tell you the process answers, not that its jobs run.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Metrics.&lt;/strong&gt; A timer on each job helps, but catching a job that stopped means writing an alert on &lt;em&gt;absence&lt;/em&gt;, for each job, and keeping those rules in step with the code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reading the list of scheduled tasks.&lt;/strong&gt; Actuator’s &lt;code&gt;scheduledtasks&lt;/code&gt; endpoint shows each task’s next and last execution, so a stuck run is visible there if someone looks. Nothing alerts on it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to be alerted when a scheduled job stops
&lt;/h2&gt;

&lt;p&gt;The reliable signal is the one that fails in the right direction: the job reports &lt;strong&gt;every successful run&lt;/strong&gt; to an outside service, which expects it on a schedule and alerts when it does not come. That is a &lt;a href="https://silencewatch.com/dead-mans-switch/" rel="noopener noreferrer"&gt;dead man’s switch&lt;/a&gt;. A stuck thread, a missing annotation, a disabled cron and a dead instance all raise the same alert: the heartbeat did not arrive.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to fix a stuck scheduler
&lt;/h2&gt;

&lt;p&gt;Being alerted is the first half. For the stuck-thread case, the usual remedies are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;put a timeout on every outgoing call&lt;/strong&gt; a job makes (HTTP client, database, queue): a job that can wait forever eventually will;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;give the scheduler more than one thread&lt;/strong&gt;, so one slow job cannot hold the others back: &lt;code&gt;spring.task.scheduling.pool.size: 5&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;keep long jobs out of the scheduler thread&lt;/strong&gt;, by handing the work to an executor and returning; if the heartbeat is sent when the scheduled method returns, it marks the hand-off, not the work, so send it at the end of the work itself, or prefer the two fixes above.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Why did my &lt;code&gt;@Scheduled&lt;/code&gt; method stop running without an error?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The usual causes are another scheduled method that never returns (Spring Boot runs them all on one thread by default), scheduling not enabled, a cron disabled with the value &lt;code&gt;-&lt;/code&gt;, or an application instance that is no longer running. None of them writes a log line.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What happens when a &lt;code&gt;@Scheduled&lt;/code&gt; method throws an exception?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For a repeating task, Spring logs the exception at ERROR level and runs the method again at its next scheduled time. The job does not stop, but it can fail on every run without anyone being told.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How many threads does Spring use for &lt;code&gt;@Scheduled&lt;/code&gt; methods?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One by default in Spring Boot. Raise &lt;code&gt;spring.task.scheduling.pool.size&lt;/code&gt; so that a slow job does not delay the others.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How can I be alerted when a scheduled job stops?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Have the job report each successful run to a service that expects it on a schedule and alerts when it is missing, a dead man’s switch.&lt;/p&gt;

&lt;h2&gt;
  
  
  See also
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://silencewatch.com/blog/cron-not-running/" rel="noopener noreferrer"&gt;Cron job not running&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://silencewatch.com/blog/quartz-job-not-firing/" rel="noopener noreferrer"&gt;Quartz job not firing? Causes and how to check&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://silencewatch.com/blog/spring-scheduled-job-stops/" rel="noopener noreferrer"&gt;SilenceWatch blog&lt;/a&gt;. This article was written with the help of AI and checked against the sources before publishing.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>springboot</category>
      <category>monitoring</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
