跳到主要内容

计划任务 (scheduledtasks)

DeepSeek V3 中英对照 Scheduled Tasks (scheduledtasks) Scheduled Tasks (scheduledtasks)

scheduledtasks 端点提供了有关应用程序的计划任务的信息。

获取计划任务

要检索计划任务,请向 /actuator/scheduledtasks 发起 GET 请求,如下面的基于 curl 的示例所示:

$ curl 'http://localhost:8080/actuator/scheduledtasks' -i -X GET
bash

生成的响应类似于以下内容:

HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 1222

{
"cron" : [ {
"runnable" : {
"target" : "com.example.Processor.processOrders"
},
"expression" : "0 0 0/3 1/1 * ?",
"nextExecution" : {
"time" : "2025-01-23T11:59:59.999232713Z"
}
} ],
"fixedDelay" : [ {
"runnable" : {
"target" : "com.example.Processor.purge"
},
"initialDelay" : 0,
"interval" : 5000,
"nextExecution" : {
"time" : "2025-01-23T11:07:09.709795283Z"
},
"lastExecution" : {
"time" : "2025-01-23T11:07:04.705583565Z",
"status" : "SUCCESS"
}
} ],
"fixedRate" : [ {
"runnable" : {
"target" : "com.example.Processor.retrieveIssues"
},
"initialDelay" : 10000,
"interval" : 3000,
"nextExecution" : {
"time" : "2025-01-23T11:07:14.696266122Z"
}
} ],
"custom" : [ {
"runnable" : {
"target" : "com.example.Processor$CustomTriggeredRunnable@12f40682"
},
"trigger" : "com.example.Processor$CustomTrigger@7bd7012d",
"lastExecution" : {
"exception" : {
"message" : "Failed while running custom task",
"type" : "java.lang.IllegalStateException"
},
"time" : "2025-01-23T11:07:04.760648151Z",
"status" : "ERROR"
}
} ]
}
http

响应结构

响应内容包含应用程序的预定任务详情。下表描述了响应的结构:

路径类型描述
cronArray定时任务,如果有的话。
cron.[].runnable.targetString将要执行的目标。
cron.[].nextExecution.timeString下一次计划执行的时间。
cron.[].expressionStringCron 表达式。
fixedDelayArray固定延迟任务,如果有的话。
fixedDelay.[].runnable.targetString将要执行的目标。
fixedDelay.[].initialDelayNumber首次执行前的延迟时间,单位为毫秒。
fixedDelay.[].nextExecution.timeString下一次计划执行的时间,如果已知的话。
fixedDelay.[].intervalNumber上一次执行结束到下一次执行开始之间的间隔时间,单位为毫秒。
fixedRateArray固定速率任务,如果有的话。
fixedRate.[].runnable.targetString将要执行的目标。
fixedRate.[].intervalNumber每次执行开始之间的间隔时间,单位为毫秒。
fixedRate.[].initialDelayNumber首次执行前的延迟时间,单位为毫秒。
fixedRate.[].nextExecution.timeString下一次计划执行的时间,如果已知的话。
customArray自定义触发器的任务,如果有的话。
custom.[].runnable.targetString将要执行的目标。
custom.[].triggerString任务的触发器。
*.[].lastExecutionObject该任务的上一次执行,如果有的话。
*.[].lastExecution.statusString上一次执行的状态(STARTED, SUCCESS, ERROR)。
*.[].lastExecution.timeString上一次执行的时间。
*.[].lastExecution.exception.typeString任务抛出的异常类型,如果有的话。
*.[].lastExecution.exception.messageString任务抛出的异常消息,如果有的话。