定时任务(计划任务)
这计划任务端点提供关于应用程序调度任务的信息。
检索预定任务
要检索排程任务,请设置获取请求/执行器/调度任务如以下基于卷度的示例所示:
$ 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: 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"
}
} ]
}
响应结构
响应包含应用程序调度任务的详细信息。下表描述了响应的结构:
| 路径 | 类型 | 描述 |
|---|---|---|
|
|
如果有克朗任务的话。 |
|
|
目标将被执行。 |
|
|
下一次预定执行的时间。 |
|
|
克朗表情。 |
|
|
如果有固定延迟任务的话。 |
|
|
目标将被执行。 |
|
|
延迟,按毫秒计,在首次执行前。 |
|
|
如果已知,下一次预定执行的时间。 |
|
|
间隔,以毫秒计,介于上一次执行结束与下一次执行开始之间。 |
|
|
如果有固定费率的任务。 |
|
|
目标将被执行。 |
|
|
每次执行开始之间的间隔,以毫秒计。 |
|
|
延迟,按毫秒计,在首次执行前。 |
|
|
如果已知,下一次预定执行的时间。 |
|
|
如果有自定义触发器的任务。 |
|
|
目标将被执行。 |
|
|
任务的触发点。 |
|
|
如果有的话,是这项任务的最后一次执行。 |
|
|
最后一次执行状态(启动、成功、错误)。 |
|
|
最后一次执行的时间。 |
|
|
任务抛出的异常类型(如果有的话)。 |
|
|
任务抛出的异常消息(如果有的话)。 |