From 019781f9ee6668f49196ecbe4838671777ce1919 Mon Sep 17 00:00:00 2001 From: Dict Xiong Date: Mon, 1 Apr 2024 22:16:34 +0800 Subject: [PATCH] fix(install.sh): crontab fails on a new server --- install.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 50a1ca0..24ffba3 100755 --- a/install.sh +++ b/install.sh @@ -203,9 +203,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 - echo -n | crontab - + echo "$CRON_JOB" | crontab - + else + ( crontab -l | grep -vxF "${CRON_JOB}" | grep -v "no crontab for"; echo "$CRON_JOB" ) | crontab - fi - ( crontab -l | grep -vxF "${CRON_JOB}" | grep -v "no crontab for"; echo "$CRON_JOB" ) | crontab - else fmt_warning "crontab does not exist. skipping ..." fi