From cc238dedbc743644815f58db8d6d844d23bbe9a4 Mon Sep 17 00:00:00 2001 From: hanhh <18330117883@163.com> Date: Wed, 14 Jul 2021 15:40:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9tee=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/api.sh | 4 ++-- shell/task.sh | 30 +++++++++++++++--------------- shell/update.sh | 14 +++++++------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/shell/api.sh b/shell/api.sh index aeaa545f..b21bec24 100755 --- a/shell/api.sh +++ b/shell/api.sh @@ -170,9 +170,9 @@ update_cron() { code=$(echo $api | jq -r .code) message=$(echo $api | jq -r .message) if [[ $code == 200 ]]; then - echo -e "## 更新任务状态成功" | tee -a $log_path + echo -e "## 更新任务状态成功" | tee --output-error=warn -a $log_path else - echo -e "## 更新任务状态失败(${message})" | tee -a $log_path + echo -e "## 更新任务状态失败(${message})" | tee --output-error=warn -a $log_path fi } diff --git a/shell/task.sh b/shell/task.sh index a3db82c2..6d3d5e19 100755 --- a/shell/task.sh +++ b/shell/task.sh @@ -91,25 +91,25 @@ run_normal() { local id=$(cat $list_crontab_user | grep -E "$cmd_task $p1" | perl -pe "s|.*ID=(.*) $cmd_task $p1\.*|\1|" | head -1 | awk -F " " '{print $1}') local begin_time=$(date '+%Y-%m-%d %H:%M:%S') - echo -e "## 开始执行... $begin_time\n" | tee -a $log_path + echo -e "## 开始执行... $begin_time\n" | tee --output-error=warn -a $log_path [[ $id ]] && update_cron "\"$id\"" "0" "$$" "$log_path" if [[ ! $(. $file_task_before) ]]; then . $file_task_before else - echo -e "## task_before执行失败,自行检查\n" | tee -a $log_path + echo -e "## task_before执行失败,自行检查\n" | tee --output-error=warn -a $log_path fi - timeout $command_timeout_time $which_program $p1 2>&1 | tee -a $log_path + timeout $command_timeout_time $which_program $p1 2>&1 | tee --output-error=warn -a $log_path if [[ ! $(. $file_task_after) ]]; then . $file_task_after else - echo -e "## task_after执行失败,自行检查\n" | tee -a $log_path + echo -e "## task_after执行失败,自行检查\n" | tee --output-error=warn -a $log_path fi [[ $id ]] && update_cron "\"$id\"" "1" "" "$log_path" local end_time=$(date '+%Y-%m-%d %H:%M:%S') local diff_time=$(($(date +%s -d "$end_time") - $(date +%s -d "$begin_time"))) - echo -e "\n## 执行结束... $end_time 耗时 $diff_time 秒" | tee -a $log_path + echo -e "\n## 执行结束... $end_time 耗时 $diff_time 秒" | tee --output-error=warn -a $log_path } ## 并发执行时,设定的 RandomDelay 不会生效,即所有任务立即执行 @@ -133,14 +133,14 @@ run_concurrent() { local id=$(cat $list_crontab_user | grep -E "$cmd_task $p1" | perl -pe "s|.*ID=(.*) $cmd_task $p1\.*|\1|" | head -1 | awk -F " " '{print $1}') local begin_time=$(date '+%Y-%m-%d %H:%M:%S') - echo -e "## 开始执行... $begin_time\n" | tee -a $log_path + echo -e "## 开始执行... $begin_time\n" | tee --output-error=warn -a $log_path [[ $id ]] && update_cron "\"$id\"" "0" "$$" "$log_path" if [[ ! $(. $file_task_before) ]]; then . $file_task_before else - echo -e "## task_before执行失败,自行检查\n" | tee -a $log_path + echo -e "## task_before执行失败,自行检查\n" | tee --output-error=warn -a $log_path fi - echo -e "\n各账号间已经在后台开始并发执行,前台不输入日志,日志直接写入文件中。\n" | tee -a $log_path + echo -e "\n各账号间已经在后台开始并发执行,前台不输入日志,日志直接写入文件中。\n" | tee --output-error=warn -a $log_path single_log_time=$(date "+%Y-%m-%d-%H-%M-%S.%N") for i in "${!array[@]}"; do @@ -152,12 +152,12 @@ run_concurrent() { if [[ ! $(. $file_task_after) ]]; then . $file_task_after else - echo -e "## task_after执行失败,自行检查\n" | tee -a $log_path + echo -e "## task_after执行失败,自行检查\n" | tee --output-error=warn -a $log_path fi [[ $id ]] && update_cron "\"$id\"" "1" "" "$log_path" local end_time=$(date '+%Y-%m-%d %H:%M:%S') local diff_time=$(($(date +%s -d "$end_time") - $(date +%s -d "$begin_time"))) - echo -e "\n## 执行结束... $end_time 耗时 $diff_time 秒" | tee -a $log_path + echo -e "\n## 执行结束... $end_time 耗时 $diff_time 秒" | tee --output-error=warn -a $log_path } ## 运行其他命令 @@ -170,25 +170,25 @@ run_else() { local id=$(cat $list_crontab_user | grep -E "$cmd_task $p1" | perl -pe "s|.*ID=(.*) $cmd_task $p1\.*|\1|" | head -1 | awk -F " " '{print $1}') local begin_time=$(date '+%Y-%m-%d %H:%M:%S') - echo -e "## 开始执行... $begin_time\n" | tee -a $log_path + echo -e "## 开始执行... $begin_time\n" | tee --output-error=warn -a $log_path [[ $id ]] && update_cron "\"$id\"" "0" "$$" "$log_path" if [[ ! $(. $file_task_before) ]]; then . $file_task_before else - echo -e "## task_before执行失败,自行检查\n" | tee -a $log_path + echo -e "## task_before执行失败,自行检查\n" | tee --output-error=warn -a $log_path fi - timeout $command_timeout_time "$@" 2>&1 | tee -a $log_path + timeout $command_timeout_time "$@" 2>&1 | tee --output-error=warn -a $log_path if [[ ! $(. $file_task_after) ]]; then . $file_task_after else - echo -e "## task_after执行失败,自行检查\n" | tee -a $log_path + echo -e "## task_after执行失败,自行检查\n" | tee --output-error=warn -a $log_path fi [[ $id ]] && update_cron "\"$id\"" "1" "" "$log_path" local end_time=$(date '+%Y-%m-%d %H:%M:%S') local diff_time=$(($(date +%s -d "$end_time") - $(date +%s -d "$begin_time"))) - echo -e "\n## 执行结束... $end_time 耗时 $diff_time 秒" | tee -a $log_path + echo -e "\n## 执行结束... $end_time 耗时 $diff_time 秒" | tee --output-error=warn -a $log_path } ## 命令检测 diff --git a/shell/update.sh b/shell/update.sh index 04cad346..9250cca5 100755 --- a/shell/update.sh +++ b/shell/update.sh @@ -403,11 +403,11 @@ main() { case $p1 in update) echo -e "## 开始执行... $begin_time\n" >> $log_path - update_qinglong "$2" | tee -a $log_path + update_qinglong "$2" | tee --output-error=warn -a $log_path ;; extra) echo -e "## 开始执行... $begin_time\n" >> $log_path - run_extra_shell | tee -a $log_path + run_extra_shell | tee --output-error=warn -a $log_path ;; repo) get_user_info @@ -415,7 +415,7 @@ main() { log_path="$dir_log/update/${log_time}_$name.log" echo -e "## 开始执行... $begin_time\n" >> $log_path if [[ -n $p2 ]]; then - update_repo "$p2" "$p3" "$p4" "$p5" "$p6" | tee -a $log_path + update_repo "$p2" "$p3" "$p4" "$p5" "$p6" | tee --output-error=warn -a $log_path else echo -e "命令输入错误...\n" usage @@ -427,7 +427,7 @@ main() { log_path="$dir_log/update/${log_time}_$name.log" echo -e "## 开始执行... $begin_time\n" >> $log_path if [[ -n $p2 ]]; then - update_raw "$p2" | tee -a $log_path + update_raw "$p2" | tee --output-error=warn -a $log_path else echo -e "命令输入错误...\n" usage @@ -435,15 +435,15 @@ main() { ;; rmlog) echo -e "## 开始执行... $begin_time\n" >> $log_path - . $dir_shell/rmlog.sh "$p2" | tee -a $log_path + . $dir_shell/rmlog.sh "$p2" | tee --output-error=warn -a $log_path ;; bot) echo -e "## 开始执行... $begin_time\n" >> $log_path - . $dir_shell/bot.sh | tee -a $log_path + . $dir_shell/bot.sh | tee --output-error=warn -a $log_path ;; check) echo -e "## 开始执行... $begin_time\n" >> $log_path - . $dir_shell/check.sh | tee -a $log_path + . $dir_shell/check.sh | tee --output-error=warn -a $log_path ;; *) echo -e "命令输入错误...\n"