From 36921b45c113e9a3be2deee92d341001f7fe0aa3 Mon Sep 17 00:00:00 2001 From: whyour Date: Mon, 10 May 2021 18:36:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=A0=E9=99=A4cron=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/update.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/shell/update.sh b/shell/update.sh index 182c4337..7fdb1429 100755 --- a/shell/update.sh +++ b/shell/update.sh @@ -112,16 +112,19 @@ del_cron() { local ids="" echo -e "开始尝试自动删除失效的定时任务...\n" for cron in $(cat $list_drop); do - local id=$(cat $list_crontab_user | grep -E "$cmd_task $cron$" | perl -pe "s|.*ID=(.*) $cmd_task $cron$|\1|") + local id=$(cat $list_crontab_user | grep -E "$cmd_task $cron$" | perl -pe "s|.*ID=(.*) $cmd_task $cron$|\1|" | xargs | sed 's/ /","/g') if [[ $ids ]]; then ids="$ids,\"$id\"" else ids="\"$id\"" fi - cron_name=$(grep "new Env" "$dir_scripts/${cron}" | awk -F "'|\"" '{print $2}' | head -1) + cron_file="$dir_scripts/${cron}" + if [[ -f $cron_file ]]; then + cron_name=$(grep "new Env" $cron_file | awk -F "'|\"" '{print $2}' | head -1) + fi [[ -z $cron_name ]] && cron_name="$cron" detail="${detail}\n${cron_name}" - rm -f "$dir_scripts/${cron}" + rm -f $cron_file done result=$(del_cron_api "$ids") detail="${result}\n${detail}"