From b31bcfe44b7dc50aaeed17ddbd7307c68e54f60a Mon Sep 17 00:00:00 2001 From: "xiongdian.me" Date: Tue, 16 Apr 2024 17:41:49 +0800 Subject: [PATCH] fix(install.sh): install crontab (exp) --- install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 24ffba3..5c54181 100755 --- a/install.sh +++ b/install.sh @@ -202,10 +202,10 @@ install_crontab() { if [[ -x $(command -v crontab) ]]; then fmt_note "installing \"$CRON_JOB\" to crontab ..." - if ! crontab -l 1>/dev/null 2>&1; then + if [[ -z "$(crontab -l 2>/dev/null || true)" ]]; then echo "$CRON_JOB" | crontab - - else - ( crontab -l | grep -vxF "${CRON_JOB}" | grep -v "no crontab for"; echo "$CRON_JOB" ) | crontab - + elif !( crontab -l | grep -qxF "${CRON_JOB}"); then + ( crontab -l; echo "$CRON_JOB" ) | crontab - fi else fmt_warning "crontab does not exist. skipping ..."