fix(install.sh): install crontab (exp)

This commit is contained in:
xiongdian.me 2024-04-16 17:41:49 +08:00
parent c8c3289c79
commit b31bcfe44b

View File

@ -202,10 +202,10 @@ install_crontab()
{ {
if [[ -x $(command -v crontab) ]]; then if [[ -x $(command -v crontab) ]]; then
fmt_note "installing \"$CRON_JOB\" to crontab ..." 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 - echo "$CRON_JOB" | crontab -
else elif !( crontab -l | grep -qxF "${CRON_JOB}"); then
( crontab -l | grep -vxF "${CRON_JOB}" | grep -v "no crontab for"; echo "$CRON_JOB" ) | crontab - ( crontab -l; echo "$CRON_JOB" ) | crontab -
fi fi
else else
fmt_warning "crontab does not exist. skipping ..." fmt_warning "crontab does not exist. skipping ..."