定时任务 (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: 1207
{
"cron" : [ {
"runnable" : {
"target" : "com.example.Processor.processOrders"
},
"expression" : "0 0 0/3 1/1 * ?",
"nextExecution" : {
"time" : "2025-05-25T12:59:59.999308Z"
}
} ],
"fixedDelay" : [ {
"runnable" : {
"target" : "com.example.Processor.purge"
},
"initialDelay" : 0,
"interval" : 5000,
"lastExecution" : {
"status" : "SUCCESS",
"time" : "2025-05-25T10:03:21.704617Z"
},
"nextExecution" : {
"time" : "2025-05-25T10:03:26.706930Z"
}
} ],
"fixedRate" : [ {
"runnable" : {
"target" : "com.example.Processor.retrieveIssues"
},
"initialDelay" : 10000,
"interval" : 3000,
"nextExecution" : {
"time" : "2025-05-25T10:03:31.704280Z"
}
} ],
"custom" : [ {
"runnable" : {
"target" : "com.example.Processor$CustomTriggeredRunnable@11ef3bee"
},
"trigger" : "com.example.Processor$CustomTrigger@1c018f41",
"lastExecution" : {
"status" : "ERROR",
"exception" : {
"message" : "Failed while running custom task",
"type" : "java.lang.IllegalStateException"
},
"time" : "2025-05-25T10:03:22.033344Z"
}
} ]
}
响应结构
响应包含应用程序定时任务的详细信息。 下表描述了响应的结构:
Path | Type | Description |
---|---|---|
|
|
Cron tasks, if any. |
|
|
Target that will be executed. |
|
|
Time of the next scheduled execution. |
|
|
Cron expression. |
|
|
Fixed delay tasks, if any. |
|
|
Target that will be executed. |
|
|
Delay, in milliseconds, before first execution. |
|
|
Time of the next scheduled execution, if known. |
|
|
Interval, in milliseconds, between the end of the last execution and the start of the next. |
|
|
Fixed rate tasks, if any. |
|
|
Target that will be executed. |
|
|
Interval, in milliseconds, between the start of each execution. |
|
|
Delay, in milliseconds, before first execution. |
|
|
Time of the next scheduled execution, if known. |
|
|
Tasks with custom triggers, if any. |
|
|
Target that will be executed. |
|
|
Trigger for the task. |
|
|
Last execution of this task, if any. |
|
|
Status of the last execution (STARTED, SUCCESS, ERROR). |
|
|
Time of the last execution. |
|
|
Exception type thrown by the task, if any. |
|
|
Message of the exception thrown by the task, if any. |