|
如需获取最新稳定版本,请使用 Spring Boot 4.0.4! |
定时任务(scheduledtasks)
scheduledtasks 端点提供有关应用程序已计划任务的信息。
检索已计划的任务
要检索已调度的任务,请向 /actuator/scheduledtasks 发送一个 GET 请求,如下方基于 curl 的示例所示:
$ curl 'http://localhost:8080/actuator/scheduledtasks' -i -X GET
生成的响应类似于以下内容:
HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 1221
{
"cron" : [ {
"runnable" : {
"target" : "com.example.Processor.processOrders"
},
"expression" : "0 0 0/3 1/1 * ?",
"nextExecution" : {
"time" : "2026-03-19T11:59:59.999126749Z"
}
} ],
"fixedDelay" : [ {
"runnable" : {
"target" : "com.example.Processor.purge"
},
"initialDelay" : 0,
"interval" : 5000,
"nextExecution" : {
"time" : "2026-03-19T11:01:17.509797507Z"
},
"lastExecution" : {
"time" : "2026-03-19T11:01:12.496311498Z",
"status" : "SUCCESS"
}
} ],
"fixedRate" : [ {
"runnable" : {
"target" : "com.example.Processor.retrieveIssues"
},
"initialDelay" : 10000,
"interval" : 3000,
"nextExecution" : {
"time" : "2026-03-19T11:01:22.477558741Z"
}
} ],
"custom" : [ {
"runnable" : {
"target" : "com.example.Processor$CustomTriggeredRunnable@b439e50"
},
"trigger" : "com.example.Processor$CustomTrigger@48b4fecb",
"lastExecution" : {
"exception" : {
"message" : "Failed while running custom task",
"type" : "java.lang.IllegalStateException"
},
"time" : "2026-03-19T11:01:12.539514046Z",
"status" : "ERROR"
}
} ]
}
响应结构
响应包含应用程序已计划任务的详细信息。 以下表格描述了响应的结构:
| 路径 | 类型 | 描述 |
|---|---|---|
|
|
Cron 任务(如有)。 |
|
|
将要执行的目标。 |
|
|
下次计划执行的时间。 |
|
|
Cron 表达式。 |
|
|
固定延迟任务(如果存在)。 |
|
|
将要执行的目标。 |
|
|
首次执行前的延迟时间(毫秒)。 |
|
|
下次计划执行的时间(如果已知)。 |
|
|
上一次执行结束与下一次执行开始之间的间隔(毫秒)。 |
|
|
固定频率任务(如有)。 |
|
|
将要执行的目标。 |
|
|
每次执行开始之间的间隔(毫秒)。 |
|
|
首次执行前的延迟时间(毫秒)。 |
|
|
下次计划执行的时间(如果已知)。 |
|
|
具有自定义触发器的任务(如有)。 |
|
|
将要执行的目标。 |
|
|
任务触发器。 |
|
|
此任务的上次执行时间(如果存在)。 |
|
|
上次执行的状态(STARTED、SUCCESS、ERROR)。 |
|
|
上次执行的时间。 |
|
|
(如有)任务抛出的异常类型。 |
|
|
任务抛出的异常的消息(如果存在)。 |