From b17286b73b82dd0f050c33967ab8a14f529bb902 Mon Sep 17 00:00:00 2001 From: juewuy Date: Sat, 31 Jan 2026 17:26:48 +0800 Subject: [PATCH] =?UTF-8?q?~=E4=BC=98=E5=8C=96=E5=AE=9A=E6=97=B6=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E5=AE=9E=E7=8E=B0=EF=BC=8C=E5=B0=9D=E8=AF=95=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=84=8F=E5=A4=96=E6=B8=85=E7=A9=BA=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=86=85=E5=AE=B9=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/libs/core_tools.sh | 2 +- scripts/libs/set_cron.sh | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/libs/core_tools.sh b/scripts/libs/core_tools.sh index 42d6cbba..39f54253 100644 --- a/scripts/libs/core_tools.sh +++ b/scripts/libs/core_tools.sh @@ -23,7 +23,7 @@ core_unzip() { #$1:需要解压的文件 $2:目标文件名 } core_find(){ if [ ! -f "$TMPDIR"/CrashCore ];then - [ -n "$(find "$CRASHDIR"/CrashCore.* $find_para 2>/dev/null)" ] && + [ -n "$(find "$CRASHDIR"/CrashCore.* $find_para 2>/dev/null)" ] && [ "$CRASHDIR" != "$BINDIR" ] && mv -f "$CRASHDIR"/CrashCore.* "$BINDIR"/ core_dir=$(find "$BINDIR"/CrashCore.* $find_para 2>/dev/null | head -n 1) [ -n "$core_dir" ] && core_unzip "$core_dir" CrashCore diff --git a/scripts/libs/set_cron.sh b/scripts/libs/set_cron.sh index d93c776c..a38feb0a 100644 --- a/scripts/libs/set_cron.sh +++ b/scripts/libs/set_cron.sh @@ -3,15 +3,16 @@ crondir="$(crond -h 2>&1 | grep -oE 'Default:.*' | awk -F ":" '{print $2}')" [ ! -w "$crondir" ] && crondir="/etc/storage/cron/crontabs" [ ! -w "$crondir" ] && crondir="/var/spool/cron/crontabs" [ ! -w "$crondir" ] && crondir="/var/spool/cron" -tmpcron="$TMPDIR"/cron_tmp +tmpcron=/tmp/cron_tmp +touch "$tmpcron" croncmd() { #定时任务工具 - if [ -n "$(crontab -h 2>&1 | grep '\-l')" ]; then - crontab "$1" - elif [ -w "$crondir" ] && [ -n "$USER" ];then + if [ -w "$crondir" ] && [ -n "$USER" ];then [ "$1" = "-l" ] && cat "$crondir"/"$USER" 2>/dev/null [ -f "$1" ] && cat "$1" >"$crondir"/"$USER" killall -HUP crond 2>/dev/null + elif [ -n "$(crontab -h 2>&1 | grep '\-l')" ]; then + crontab "$1" else echo "找不到可用的crond或者crontab应用!No available crond or crontab application can be found!" fi @@ -20,7 +21,6 @@ cronset() { #定时任务设置 # 参数1代表要移除的关键字,参数2代表要添加的任务语句 croncmd -l >"$tmpcron" sed -i "/$1/d" "$tmpcron" - sed -i '/^$/d' "$tmpcron" echo "$2" >>"$tmpcron" croncmd "$tmpcron" rm -f "$tmpcron"