fix empty cron

This commit is contained in:
leo 2024-08-18 11:07:02 +05:00
parent 1d146dd0d4
commit 22981eac7f

View File

@ -14,7 +14,7 @@ if [ ! -f $CRON_LIST ]; then
fi fi
echo "Reading current crontab jobs into a variable..." 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..." echo "Iterate through the lines of the cron.list file..."
while IFS= read -r line; do while IFS= read -r line; do
@ -28,7 +28,7 @@ while IFS= read -r line; do
echo "The task already exists: $line" echo "The task already exists: $line"
else else
echo "Adding a job to crontab..." echo "Adding a job to crontab..."
(crontab -l; echo "$line") | crontab - (crontab -l 2>/dev/null || true; echo "$line") | crontab -
echo "Task added: $line" echo "Task added: $line"
fi fi
done < "$CRON_LIST" done < "$CRON_LIST"