計劃任務 (scheduledtasks)
scheduledtasks 端點提供有關應用程式計劃任務的資訊。
檢索計劃任務
要檢索計劃任務,請向 /actuator/scheduledtasks 傳送 GET 請求,如以下基於 curl 的示例所示
$ curl 'https://:8080/actuator/scheduledtasks' -i -X GET
結果響應類似於以下內容
HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 1222
{
"cron" : [ {
"expression" : "0 0 0/3 1/1 * ?",
"nextExecution" : {
"time" : "2025-11-20T17:59:59.999073346Z"
},
"runnable" : {
"target" : "com.example.Processor.processOrders"
}
} ],
"custom" : [ {
"lastExecution" : {
"exception" : {
"message" : "Failed while running custom task",
"type" : "java.lang.IllegalStateException"
},
"status" : "ERROR",
"time" : "2025-11-20T16:33:59.854299429Z"
},
"runnable" : {
"target" : "com.example.Processor$CustomTriggeredRunnable@7cc19564"
},
"trigger" : "com.example.Processor$CustomTrigger@3cd39478"
} ],
"fixedDelay" : [ {
"initialDelay" : 0,
"interval" : 5000,
"lastExecution" : {
"status" : "SUCCESS",
"time" : "2025-11-20T16:33:59.818361640Z"
},
"nextExecution" : {
"time" : "2025-11-20T16:34:04.825810594Z"
},
"runnable" : {
"target" : "com.example.Processor.purge"
}
} ],
"fixedRate" : [ {
"initialDelay" : 10000,
"interval" : 3000,
"nextExecution" : {
"time" : "2025-11-20T16:34:09.804341635Z"
},
"runnable" : {
"target" : "com.example.Processor.retrieveIssues"
}
} ]
}
響應結構
響應包含應用程式計劃任務的詳細資訊。下表描述了響應的結構
| 路徑 | 型別 | 描述 |
|---|---|---|
|
|
Cron 任務(如果有)。 |
|
|
將被執行的目標。 |
|
|
下一次計劃執行的時間。 |
|
|
Cron 表示式。 |
|
|
固定延遲任務(如果有)。 |
|
|
將被執行的目標。 |
|
|
首次執行前的延遲(毫秒)。 |
|
|
下一次計劃執行的時間(如果已知)。 |
|
|
上次執行結束與下次執行開始之間的間隔(毫秒)。 |
|
|
固定頻率任務(如果有)。 |
|
|
將被執行的目標。 |
|
|
每次執行開始之間的間隔(毫秒)。 |
|
|
首次執行前的延遲(毫秒)。 |
|
|
下一次計劃執行的時間(如果已知)。 |
|
|
具有自定義觸發器的任務(如果有)。 |
|
|
將被執行的目標。 |
|
|
任務的觸發器。 |
|
|
此任務的上次執行(如果有)。 |
|
|
上次執行的狀態 (STARTED, SUCCESS, ERROR)。 |
|
|
上次執行的時間。 |
|
|
任務丟擲的異常型別(如果有)。 |
|
|
任務丟擲的異常訊息(如果有)。 |