From 22981eac7fbc54f152eacf5f1ca4036fb011028e Mon Sep 17 00:00:00 2001 From: leo <426742@gmail.com> Date: Sun, 18 Aug 2024 11:07:02 +0500 Subject: [PATCH] fix empty cron --- cron-list.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cron-list.sh b/cron-list.sh index 813e1c2..9057440 100644 --- a/cron-list.sh +++ b/cron-list.sh @@ -14,7 +14,7 @@ if [ ! -f $CRON_LIST ]; then fi echo "Reading current crontab jobs into a variable..." -current_crontab=$(crontab -l 2>/dev/null || :) +current_crontab=$(crontab -l 2>/dev/null || true) echo "Iterate through the lines of the cron.list file..." while IFS= read -r line; do @@ -28,7 +28,7 @@ while IFS= read -r line; do echo "The task already exists: $line" else echo "Adding a job to crontab..." - (crontab -l; echo "$line") | crontab - + (crontab -l 2>/dev/null || true; echo "$line") | crontab - echo "Task added: $line" fi done < "$CRON_LIST"