From ed259e81684f648e76092c9501aff2e3da34f026 Mon Sep 17 00:00:00 2001 From: whyour Date: Sat, 15 Oct 2022 18:29:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20task=20=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E6=97=B6=E5=8F=82=E6=95=B0=E5=BC=95=E5=8F=B7?= =?UTF-8?q?=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/services/cron.ts | 2 +- shell/task.sh | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/back/services/cron.ts b/back/services/cron.ts index 8ce2774f..8471df21 100644 --- a/back/services/cron.ts +++ b/back/services/cron.ts @@ -420,7 +420,7 @@ export default class CronService { ); cp.stderr.on('data', (data) => { if (logFileExist) { - fs.appendFileSync(`${absolutePath}`, `${data}`); + fs.appendFileSync(`${absolutePath}`, `${data.toString()}`); } }); cp.on('error', (err) => { diff --git a/shell/task.sh b/shell/task.sh index 11001d46..9e523980 100755 --- a/shell/task.sh +++ b/shell/task.sh @@ -156,7 +156,7 @@ handle_task_after() { local end_timestamp=$(date "+%s") local diff_time=$(($end_timestamp - $begin_timestamp)) [[ $ID ]] && update_cron "\"$ID\"" "1" "" "$log_path" "$begin_timestamp" "$diff_time" - eval echo -e "\\\n\#\# 执行结束... $end_time 耗时 $diff_time 秒" $cmd + eval echo -e "\\\n\\\n\#\# 执行结束... $end_time 耗时 $diff_time 秒" $cmd } ## 正常运行单个脚本,$1:传入参数 @@ -284,7 +284,9 @@ run_else() { fi shift - eval $timeoutCmd $which_program "$file_param" "$@" $cmd + + local params=$(echo "$@" | sed 's/ /\" \"/g') + eval $timeoutCmd $which_program $file_param \"$params\" $cmd handle_task_after "$@" }