From 45187f7385897283c3b9dc0c4b155737095449bf Mon Sep 17 00:00:00 2001 From: leo <426742@gmail.com> Date: Thu, 8 Aug 2024 07:05:39 +0500 Subject: [PATCH] c --- cron-list.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cron-list.sh b/cron-list.sh index 6841017..db5f177 100644 --- a/cron-list.sh +++ b/cron-list.sh @@ -1,33 +1,33 @@ #!/bin/bash -CRON_LIST=/data/config/$SRV_START_DIR/cron.cfg +CRON_LIST=/data/$SRV_START_DIR/config/cron.cfg -trap 'echo -e "\033[31mSomething went wrong\033[0m"; exit 1' EXIT +trap 'echo -e "\033[31mcrom-list.sh: Something went wrong\033[0m"; exit 1' EXIT set -e export DEBIAN_FRONTEND=noninteractive -# Checking for the presence of the cron.list file +echo "Checking for the presence of the cron.cfg file..." if [ ! -f $CRON_LIST ]; then echo "cron.cfg file not found!" exit 1 fi -# Reading current crontab jobs into a variable +echo "Reading current crontab jobs into a variable..." current_crontab=$(crontab -l 2>/dev/null) -# 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 # Skip blank lines and comments if [[ -z "$line" || "$line" == \#* ]]; then continue fi - # Checking if a job exists in the current crontab + echo "Checking if a job exists in the current crontab..." if echo "$current_crontab" | grep -Fq "$line"; then echo "The task already exists: $line" else - # Adding a job to crontab + echo "Adding a job to crontab..." (crontab -l; echo "$line") | crontab - echo "Task added: $line" fi