From b90243f55c1cde5a28b6d54dffa1a55fd5d4f2dd Mon Sep 17 00:00:00 2001 From: whyour Date: Thu, 19 Oct 2023 21:36:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20task=20=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/services/cron.ts | 2 +- shell/task.sh | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/back/services/cron.ts b/back/services/cron.ts index 3b772b06..8a7e7cc8 100644 --- a/back/services/cron.ts +++ b/back/services/cron.ts @@ -502,7 +502,7 @@ export default class CronService { if (!command.startsWith(TASK_PREFIX) && !command.startsWith(QL_PREFIX)) { command = `${TASK_PREFIX}${tab.command}`; } - let commandVariable = `ID=${tab.id} ` + let commandVariable = `no_tee=true ID=${tab.id} ` if (tab.task_before) { commandVariable += `task_before='${tab.task_before.replace(/'/g, "'\\''") .trim()}' `; diff --git a/shell/task.sh b/shell/task.sh index 1acd1a66..f6eeea12 100755 --- a/shell/task.sh +++ b/shell/task.sh @@ -70,10 +70,10 @@ handle_log_path() { log_path="$real_log_path" fi - cmd=">> $dir_log/$log_path 2>&1" + cmd="2>&1 | tee -a $dir_log/$log_path" make_dir "$dir_log/$log_dir" - if [[ "$show_log" == "true" ]]; then - cmd="2>&1 | tee -a $dir_log/$log_path" + if [[ "$no_tee" == "true" ]]; then + cmd=">> $dir_log/$log_path 2>&1" fi if [[ "$real_time" == "true" ]]; then @@ -139,7 +139,4 @@ handle_log_path "${task_shell_params[@]}" init_begin_time eval . $dir_shell/otask.sh "$cmd" -# mac cat 无法正常退出 -# [[ -f "$dir_log/$log_path" ]] && [[ ! $show_log ]] && [[ "$real_time" != "true" ]] && cat "$dir_log/$log_path" - exit 0