From 8ad26267d8557024101a0387b0788224724b5010 Mon Sep 17 00:00:00 2001 From: whyour Date: Fri, 20 Jan 2023 23:38:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20task=20before/after=20?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/otask.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/shell/otask.sh b/shell/otask.sh index 72e3446b..ee4d979e 100644 --- a/shell/otask.sh +++ b/shell/otask.sh @@ -101,6 +101,8 @@ handle_task_before() { begin_time=$(format_time "$time_format" "$time") begin_timestamp=$(format_timestamp "$time_format" "$time") + [[ $ID ]] && update_cron "\"$ID\"" "0" "$$" "$log_path" "$begin_timestamp" + echo -e "## 开始执行... $begin_time\n" [[ $is_macos -eq 0 ]] && check_server @@ -111,7 +113,6 @@ handle_task_before() { eval echo $cmd fi - [[ $ID ]] && update_cron "\"$ID\"" "0" "$$" "$log_path" "$begin_timestamp" . $file_task_before "$@" } @@ -123,9 +124,10 @@ handle_task_after() { local end_timestamp=$(format_timestamp "$time_format" "$etime") local diff_time=$(($end_timestamp - $begin_timestamp)) - [[ $ID ]] && update_cron "\"$ID\"" "1" "" "$log_path" "$begin_timestamp" "$diff_time" echo -e "\n\n## 执行结束... $end_time 耗时 $diff_time 秒" echo -e "\n     " + + [[ $ID ]] && update_cron "\"$ID\"" "1" "" "$log_path" "$begin_timestamp" "$diff_time" } ## 正常运行单个脚本,$1:传入参数