Published October 21, 2026
How to Monitor Spring Boot Scheduled Tasks
A @Scheduled method runs only when this process schedules it. The application can be up, and the method can still never run. Nothing in that process emails you. A ping after the work is the alert for that silence.
The scheduling facts below are from the Spring Framework and Spring Boot reference docs. A Linux crontab on a machine you run is crontab not running. Two copies of the same method are prevent overlapping cron jobs. Cron inside a container is cron in Docker, and a CronJob is Kubernetes CronJobs. The five fields are in cron expression examples. The general pattern is how to monitor cron jobs.
Enabling scheduling
@Scheduled is processed by a ScheduledAnnotationBeanPostProcessor. @EnableScheduling on a @Configuration class registers that processor. @EnableAsync is a different switch. Leave it off when you only need schedules.
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableScheduling
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Without @EnableScheduling, the annotation is not processed. The process can still start. The class also has to be a Spring bean. An object you build with new is not registered.
The method must not accept arguments. A return value is ignored. A repeating method specifies exactly one of cron, fixedDelay, or fixedRate. initialDelay is an optional extra on fixedRate or fixedDelay. initialDelay alone is a one-time task.
One scheduler thread
When scheduling is enabled and virtual threads are off, Spring Boot auto-configures a ThreadPoolTaskScheduler. It uses one thread by default. spring.task.scheduling.pool.size is that maximum, and the documented default is 1. New threads are named with spring.task.scheduling.thread-name-prefix, which defaults to scheduling-.
One thread means one execution at a time on that scheduler. A method that has not returned holds the thread. Every other method on that scheduler waits. A method that never returns means those others never start. Raise the pool size when the methods should not wait on each other.
spring.task.scheduling.pool.size=4
spring.threads.virtual.enabled defaults to false. Set it to true on Java 21 or newer and Boot auto-configures a SimpleAsyncTaskScheduler that uses virtual threads. That scheduler ignores pool settings, including spring.task.scheduling.pool.size. It keeps one scheduler thread and starts a thread for each fixed-rate or cron execution. Fixed-delay tasks stay on that single scheduler thread. The @Scheduled javadoc recommends fixed-rate and cron over fixed-delay for this scheduler. spring.task.scheduling.simple.concurrency-limit caps how many of those executions run at once. -1 means no cap.
Shutdown does not wait for a running task. spring.task.scheduling.shutdown.await-termination defaults to false. Set spring.task.scheduling.shutdown.await-termination-period when you turn waiting on. That property is the maximum wait. Since Spring Framework 6.1, ThreadPoolTaskScheduler also shuts down through the application lifecycle. A task that is cut off before the ping never pings.
The scheduler attribute on @Scheduled is a qualifier for a specific TaskScheduler or ScheduledExecutorService bean. An empty value, the default, uses the default scheduler.
Six fields, seconds first
Spring cron is six fields. The second is first. There is no year field.
┌───────────── second (0-59)
│ ┌───────────── minute (0-59)
│ │ ┌───────────── hour (0-23)
│ │ │ ┌───────────── day of month (1-31)
│ │ │ │ ┌───────────── month (1-12 or JAN-DEC)
│ │ │ │ │ ┌───────────── day of week (0-7, or MON-SUN)
│ │ │ │ │ │ (0 or 7 is Sunday)
* * * * * *
A field may be *. On the day-of-month or day-of-week field, ? may stand in for *. A comma is a list. A hyphen is an inclusive range. / steps through a range. Month and weekday names use the first three letters. L, W, and # are also in this format: last day, nearest weekday, and the nth weekday.
These macros replace the six fields:
| Macro | Expands to |
|---|---|
@yearly, @annually |
0 0 0 1 1 * |
@monthly |
0 0 0 1 * * |
@weekly |
0 0 0 * * 0 |
@daily, @midnight |
0 0 0 * * * |
@hourly |
0 0 * * * * |
Save five fields on the check, minute first, with no seconds field: minute, hour, day of month, month, day of week. Drop a leading 0. @daily becomes 0 0 * * *. @hourly becomes 0 * * * *. MON-FRI becomes 1-5. Replace ? with *. Prefer those five fields on the check, and read them on the cron tool before you save. If the Spring expression uses L, W, or #, do not assume the check means the same day until the cron tool lists the days you meant.
zone is the time zone the cron expression is resolved in. The default is an empty string, which means the scheduler's time zone. Set it to an id TimeZone.getTimeZone accepts, such as America/New_York or UTC, and put that same id on the check. Do not leave the check on UTC unless Spring is resolving the expression in UTC.
The value - disables the trigger. That is what a property is for: @Scheduled(cron = "${report.cron}") does not run when report.cron is -. The application stays up. The method is not scheduled.
*/10 * * * * * is every ten seconds. 0 */10 * * * * is every ten minutes, at second 0, and the check is */10 * * * *. A Spring expression that fires more often than the plan minimum cannot be a check at that cadence. Free's shortest interval is 5 minutes. Pro's is 1 minute.
timeUnit changes the unit of fixedRate, fixedDelay, and initialDelay. The default is milliseconds. It does not apply to cron.
fixedRate, fixedDelay, and a long run
fixedDelay is the gap between the end of one invocation and the start of the next. The next run waits until this one has finished.
fixedRate is the period between invocations, measured between successive start times. The task namespace describes fixed-rate as how often the method should run regardless of how long the previous execution takes.
With the default pool of one thread, a run that is still going holds the only thread, so the next start waits for it. With virtual threads enabled, a fixed-rate or cron execution gets its own thread, so a long run can still be in progress when the next one starts. Fixed-delay stays on one scheduler thread in that mode.
initialDelay waits before the first fixedRate or fixedDelay execution. It does not change the period after that. It is not a cron setting.
Two @Scheduled annotations on the same method are independent triggers. The docs say those schedules may overlap and run in parallel, or one after another.
@Scheduled(fixedRate = 15, timeUnit = TimeUnit.MINUTES)
public void everyFifteenMinutes() {
// work
}
@Scheduled(fixedDelay = 15, initialDelay = 1, timeUnit = TimeUnit.MINUTES)
public void fifteenAfterEachFinish() {
// work
}
An exception does not stop a repeating task
For a repeating task, the default error handler logs the exception and suppresses it. Later executions are not prevented. A one-time task logs the exception and propagates it. Propagating typically prevents a later execution of that scheduled task. A one-time task was not going to run again.
The lines after the throw do not run. A ping written after the work does not run for that failure. The schedule continues.
A method that returns a Publisher is a different path. An error from that publisher is logged at warning level, and later subscriptions still happen. The error handler above is not used for that path.
Two instances both run
Each application that enables scheduling registers its own callbacks. Two processes both run the method. Nothing in Spring's scheduling support picks one of them.
Nothing in that support stores the triggers either. When the schedule has to live in a job store, or only one node in a cluster should fire it, that is Quartz with a JDBC job store. The page is monitoring Quartz Scheduler jobs.
Inside one process, two instances of the same annotated class get two sets of callbacks. @Configurable on a class that is also a regular Spring bean initializes it twice, and each @Scheduled method then runs twice.
ShedLock is not part of Spring Framework or Spring Boot, and it is not a scheduler. It is a third-party lock. A lock provider stores the lock in JDBC, Redis, Mongo, or another store the library supports. @EnableSchedulerLock turns that on. @SchedulerLock(name = "nightlyReport") is what takes the lock, and only methods with that annotation are locked. If another node already holds the name, this node skips the run. It does not wait. The lock is released when the method returns, unless lockAtLeastFor keeps it longer, which is how a short task survives clock skew. lockAtMostFor is the release if the JVM dies first. Set it much longer than a normal run. If the method runs longer than lockAtMostFor, more than one process can hold the lock. The library assumes the nodes' clocks are synchronized. A skipped node does not run the method, so it does not ping. The node that got the lock is the one that must ping.
A container image with @EnableScheduling and two replicas is two processes. A lock file inside the container is not a lock the other replica can see. That case is the same one as cron in Docker and a Deployment that is not a CronJob, covered from the other side in prevent overlapping cron jobs.
What leaves no successful ping
@EnableSchedulingis missing, so the annotation is never processed. The process can still be up.- The class is not a Spring bean, or the method takes arguments, so it is not a scheduled method.
cronis-. The trigger is disabled. The application stays up.- The only scheduler thread is still inside another
@Scheduledmethod. This method has not started. - The method throws before the ping. A repeating schedule continues. That run did not ping.
- Another instance holds the ShedLock name, so this instance skips. Or no lock is in place, and both instances run.
- The process is down, or shutdown did not wait for the method. The default is not to wait.
initialDelayhas not elapsed, so the firstfixedRateorfixedDelayrun has not happened.- The work failed in a process that never sent
/failor?exit=.
CronNudge does not read the JVM, Actuator endpoints, or logs, and it cannot restart or trigger a task. It only knows about pings it receives. The application log is still where the exception from the method shows up.
Ping after the work succeeds
The success URL is https://cronnudge.com/ping/YOUR_ID. GET, POST, and HEAD all count. A stored ping answers ok with Cache-Control: no-store. YOUR_ID is the id in the ping URL, not the badge id. Anyone with that URL can send a ping. Keep the value free of a query string and of /start or /fail.
Do not hard-code it. Set the environment variable CRONNUDGE_URL. @Value("${CRONNUDGE_URL}") reads that property. If it is missing, this bean does not start.
The ping is the last step. If the work throws, those lines do not run. java.net.http.HttpClient is on the JDK. A failure to send is caught so a monitoring hiccup does not fail a method that already finished. The ping is still missed, and the check alerts after grace.
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
public class NightlyReport {
private final HttpClient http = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(10))
.build();
private final String cronnudgeUrl;
public NightlyReport(@Value("${CRONNUDGE_URL}") String cronnudgeUrl) {
this.cronnudgeUrl = cronnudgeUrl;
}
@Scheduled(cron = "0 0 3 * * *", zone = "UTC")
public void run() {
System.out.println("work");
send(base(), null);
}
private String base() {
String trimmed = cronnudgeUrl.split("\\?", 2)[0];
while (trimmed.endsWith("/")) {
trimmed = trimmed.substring(0, trimmed.length() - 1);
}
return trimmed;
}
private void send(String url, String idempotencyKey) {
HttpRequest.Builder builder = HttpRequest.newBuilder(URI.create(url))
.timeout(Duration.ofSeconds(10));
if (idempotencyKey == null) {
builder.GET();
} else {
String key = idempotencyKey.length() > 128 ? idempotencyKey.substring(0, 128) : idempotencyKey;
builder.header("Idempotency-Key", key).POST(HttpRequest.BodyPublishers.noBody());
}
try {
http.send(builder.build(), HttpResponse.BodyHandlers.discarding());
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
System.err.println("heartbeat ping failed: " + ex);
} catch (Exception ex) {
System.err.println("heartbeat ping failed: " + ex);
}
}
}
Pass the exit code
?exit= accepts an integer from 0 to 255. 0 is a success. 1 through 255 marks the check down immediately when it was not already down. Anything else is ignored, and the ping stays a success. Use this or /fail, not both.
@Scheduled(cron = "0 0 3 * * *", zone = "UTC")
public void run() {
int code = doWork();
send(base() + "?exit=" + code, null);
if (code != 0) {
throw new IllegalStateException("work failed: " + code);
}
}
/fail is the same immediate down alert. A paused check stores the ping and does not alert. A second failure while the check is already down does not send another alert. One alert when it goes down, and one when a later success recovers it.
@Scheduled(cron = "0 0 3 * * *", zone = "UTC")
public void run() {
try {
System.out.println("work");
send(base(), null);
} catch (RuntimeException ex) {
send(base() + "/fail", null);
throw ex;
}
}
A method that never starts never enters the catch. The missed success ping is the alert after grace.
/start and a max runtime
/start records a start. It is not a success. Turn on "Track start and finish," or set Max runtime (seconds), which turns run tracking on. A second /start while a run is open is an overlap alert and does not close the first run. A success or /fail closes the open runs. Two success pings alone do not raise an overlap alert.
Use one idempotency key for this start and a different key for the finish. The key is cut at 128 characters and matched per check. A repeated key is a replay. It does not open a second run and it does not send a second alert.
@Scheduled(cron = "0 0 3 * * *", zone = "UTC")
public void run() {
String id = java.util.UUID.randomUUID().toString();
send(base() + "/start", id + "-start");
System.out.println("work");
send(base(), id + "-ok");
}
The success ping still has to run after the work. Max runtime is 1 second through 7 days. With a run open and a max runtime set, the deadline becomes that start plus the max runtime. It is not the earlier of that and the schedule. No finish means one stuck alert, once for that start, and the check goes down. A later success is the recovery. With run tracking and no max runtime, an open run is due at the earlier of the schedule deadline and the start plus grace. The grace used for that run is at least 60 seconds. The alert is down, not stuck. A method that never starts never calls /start, so it cannot go stuck. Silence until the schedule deadline is the alert. Free includes run tracking on 3 checks. Pro removes that cap. Details are in assertions, runs, and agents.
Set max runtime a little past the longest healthy run. Hangs are in cron job stuck or hanging.
Match the check to the schedule
Drop the seconds field when it is 0, and set the check timezone to zone. The cron tool lists the next runs before grace is added.
The form's periods are 5 minutes, 15 minutes, 30 minutes, 1 hour, 6 hours, 1 day, and 1 week. Grace is none, 1 minute, 5 minutes (the default), 15 minutes, or 1 hour. Anything else, from the plan minimum up to 31 days for an interval and from 0 through 7 days for grace, is an API value, and the API is on Pro. Creating a check sets the first deadline from that moment. A success then moves the deadline. An interval counts from the last success. A cron expression uses the next occurrence after that success, then adds grace. An interval check stores UTC. The timezone field on the form is for cron.
Every night at 03:00 UTC. Spring 0 0 3 * * * with zone = "UTC". Check 0 3 * * *, timezone UTC. A success at 03:02 is inside the default 5 minutes of grace. The next deadline is 03:05 the next night. A run that never pings alerts at 03:05. @daily is midnight, 0 0 0 * * *, which is the check 0 0 * * *, not 03:00.
Weekdays at 09:00 in New York. Spring 0 0 9 * * MON-FRI and zone = "America/New_York". Check 0 9 * * 1-5 in that zone. A success at 09:02 is inside the default grace. The next deadline is 09:05 on the next weekday. Saturday and Sunday are not expected. Sunday is 0 or 7.
Every 15 minutes, at second 0. Spring 0 */15 * * * *. Check */15 * * * *. The gap is 15 minutes, which is longer than Free's 5-minute minimum, so it is a Free check. It fires on :00, :15, :30, and :45. A 15-minute interval check counts from the last success and stores UTC. Use the cron when the Spring expression is a cron.
Every ten seconds. Spring */10 * * * * *. The gap is 10 seconds. That is under Free's 5-minute minimum and under Pro's 1-minute minimum. It cannot be a check at that cadence.
fixedRate of 15 minutes. @Scheduled(fixedRate = 15, timeUnit = TimeUnit.MINUTES) measures start to start. It is not :00, :15, :30, and :45. An interval check of 15 minutes counts from the last success. The form lists 15 minutes. Grace covers a runtime that varies by less than the grace. A run that is still going at the deadline alerts, and the late success is the recovery. The first deadline is 15 minutes plus grace after you create the check. An initialDelay of an hour means Spring has not run yet when that deadline passes. Create the check when the first run is actually due, or the first period alerts early.
fixedDelay of 15 minutes. The next start is 15 minutes after the method returns. The gap between success pings is 15 minutes plus the runtime. An interval of 15 minutes expects the next success 15 minutes after the last one, so the runtime has to fit in the grace. A method that takes 2 minutes fits the default 5 minutes: the deadline is 20 minutes after the previous success, and the ping arrives around 17. A method that takes 10 minutes does not. The ping arrives around 25 minutes, which is past 20. Use 1 hour of grace, or an API interval of the delay plus a typical runtime. The API takes whole seconds from the plan minimum through 31 days.
Hourly. Spring 0 0 * * * *, or @hourly. Check 0 * * * *. The gap is one hour, which is longer than Free's 5-minute minimum, so it is a Free check.
Every minute, at second 0. Spring 0 * * * * *. Check * * * * *. It is valid cron, and it is not a Free check. Pro's minimum is 1 minute.
A one-time method. initialDelay with no cron, fixedRate, or fixedDelay runs once. A repeating check alerts when the next period passes and no second ping arrives. Do not put a repeating check on a method that is supposed to run once.
Free is 10 checks, a 5-minute minimum interval, email plus one Slack or Discord channel, and run tracking on 3 checks. Pro is $12 a month for 100 checks, a 1-minute minimum, signed webhooks, and the API. Details are on pricing.
FAQ
Why is a Spring @Scheduled method not running? The usual causes are that @EnableScheduling is missing, the class is not a Spring bean, or cron is set to a dash, which disables the trigger. The method must not take arguments. With the default pool of one thread, a method that has not returned holds the only scheduler thread, and the others wait. Virtual threads are off unless spring.threads.virtual.enabled is true.
Does an exception stop later runs? Not for a repeating task. The default error handler logs the exception and suppresses it, so later executions are not prevented. The lines after the throw do not run, so a ping written after the work is skipped for that failure. A one-time task logs and propagates. A Publisher error is logged and later subscriptions still happen.
Why does @Scheduled run twice? Each process that enables scheduling runs the method. Two instances run it twice. Two beans of the same annotated class in one process do that too, including a class that is both a Spring bean and @Configurable. ShedLock is a third-party lock, not part of Spring. If another node holds the lock name, this node skips instead of waiting.
How do six Spring fields become a check? Spring cron is second, minute, hour, day of month, month, day of week. Drop a leading 0 and save the other five. Put the zone attribute on the check. An empty zone means the scheduler's time zone, not necessarily UTC. A seconds step such as every ten seconds is finer than Free's 5-minute minimum and Pro's 1-minute minimum, so it cannot be a check at that cadence.
Does a failed run alert immediately? Only if a ping is sent. A ping after the work does not run when the method throws. ?exit= from 1 to 255, or /fail, marks the check down when it was not already down. exit=0 is a success. A value outside 0 to 255 is ignored. A second failure while the check is already down does not send another alert. A method that never starts never reaches the catch, so the missed success ping is the alert after grace.
Can CronNudge see the JVM or start the task? No. It does not read the JVM, Actuator endpoints, or logs, and it cannot restart or trigger a task. It only knows about pings it receives. The application log is still where an exception from the method shows up.
The scheduler calls the method. The method is what finishes the work. The ping is how you hear about the call that never came. Create the check, or read the five fields on the cron tool. Related: how to monitor cron jobs, crontab not running, cron expression examples, prevent overlapping cron jobs, cron in Docker, and Kubernetes CronJobs.