定时任务显示完整运行历史

This commit is contained in:
whyour
2026-06-28 15:48:58 +08:00
parent 5fbff0e1c8
commit d3016431ce
8 changed files with 116 additions and 136 deletions
+7 -1
View File
@@ -141,13 +141,19 @@ update_cron() {
local logPath="$4"
local lastExecutingTime="${5:-0}"
local runningTime="${6:-0}"
local exitCode="${7:-}"
local currentTimeStamp=$(date +%s)
local dataRaw="{\"ids\":[$ids],\"status\":\"$status\",\"pid\":\"$pid\",\"log_path\":\"$logPath\",\"last_execution_time\":$lastExecutingTime,\"last_running_time\":$runningTime"
if [[ -n $exitCode ]]; then
dataRaw="${dataRaw},\"exit_code\":$exitCode"
fi
dataRaw="${dataRaw}}"
local api=$(
curl -s --noproxy "*" "http://localhost:${ql_port}/open/crons/status?t=$currentTimeStamp" \
-X 'PUT' \
-H "Authorization: Bearer ${__ql_token__}" \
-H "Content-Type: application/json;charset=UTF-8" \
--data-raw "{\"ids\":[$ids],\"status\":\"$status\",\"pid\":\"$pid\",\"log_path\":\"$logPath\",\"last_execution_time\":$lastExecutingTime,\"last_running_time\":$runningTime}" \
--data-raw "$dataRaw" \
--compressed
)
code=$(echo "$api" | jq -r .code)
+1 -1
View File
@@ -414,7 +414,7 @@ handle_task_end() {
[[ "$diff_time" == 0 ]] && diff_time=1
if [[ $ID ]]; then
local error=$(update_cron "\"$ID\"" "1" "$$" "$log_path" "$begin_timestamp" "$diff_time")
local error=$(update_cron "\"$ID\"" "1" "$$" "$log_path" "$begin_timestamp" "$diff_time" "$exit_code")
if [[ $error ]]; then
error_message=", 状态更新失败(${error})"
fi