From 496e353a11e224d6ee3a2bf8709f6b75bcd27b8b Mon Sep 17 00:00:00 2001 From: juewuy Date: Fri, 16 Jan 2026 18:36:57 +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?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/libs/set_cron.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/libs/set_cron.sh b/scripts/libs/set_cron.sh index 2af0d57d..d93c776c 100644 --- a/scripts/libs/set_cron.sh +++ b/scripts/libs/set_cron.sh @@ -6,11 +6,12 @@ crondir="$(crond -h 2>&1 | grep -oE 'Default:.*' | awk -F ":" '{print $2}')" tmpcron="$TMPDIR"/cron_tmp croncmd() { #定时任务工具 - if [ -w "$crondir" ] && [ -n "$USER" ];then + if [ -n "$(crontab -h 2>&1 | grep '\-l')" ]; then + crontab "$1" + elif [ -w "$crondir" ] && [ -n "$USER" ];then [ "$1" = "-l" ] && cat "$crondir"/"$USER" 2>/dev/null [ -f "$1" ] && cat "$1" >"$crondir"/"$USER" - elif [ -n "$(crontab -h 2>&1 | grep '\-l')" ]; then - crontab "$1" + killall -HUP crond 2>/dev/null else echo "找不到可用的crond或者crontab应用!No available crond or crontab application can be found!" fi