From b54222eb23cf3efff26fca2c97a10a38b7657320 Mon Sep 17 00:00:00 2001 From: Jose Henrique Date: Mon, 6 Jan 2025 21:07:46 -0300 Subject: [PATCH] fixing crontab again phew --- scripts-download.sh | 46 ++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/scripts-download.sh b/scripts-download.sh index b526ca7..578a77d 100644 --- a/scripts-download.sh +++ b/scripts-download.sh @@ -146,30 +146,30 @@ echo -e "${GREY}[i] Setting up crontab..." # Add crontabs for FILE in "${FILES[@]}"; do if crontab -l 2>/dev/null | grep -q $FILE; then - echo -e "${LIGHT_BLUE}[i] [$FILE] Crontab already exists. Skipping.${NC}" - else - echo -e "${LIGHT_BLUE}[i] [$FILE] Adding crontab...${NC}" - - if [ "$FILE" == "clean.sh" ]; then - (crontab -l 2>/dev/null; echo "0 0 * * * ${CURRENT_WORKDIR}/$FILE > /dev/null") | crontab - - elif [ "$FILE" == "backup.sh" ]; then - (crontab -l 2>/dev/null; echo "0 0 * * * ${CURRENT_WORKDIR}/$FILE > /dev/null") | crontab - - elif [ "$FILE" == "docker-updater.sh" ]; then - (crontab -l 2>/dev/null; echo "0 3 */4 * * ${CURRENT_WORKDIR}/$FILE > /dev/null") | crontab - - else - echo -e "${YELLOW}[w] [$FILE] Warning: Crontab specific schedule not setup.${NC}" >&2 - (crontab -l 2>/dev/null; echo "0 0 * * * ${CURRENT_WORKDIR}/$FILE" > /dev/null) | crontab - - fi - - echo -e "${GREEN}[✓] [$FILE] Crontab added, double-checking set up...${NC}" - - if ! crontab -l | grep -q $FILE; then - echo -e "${RED}[x] [$FILE] Error: Crontab was not set up.${NC}" >&2 - exit 1 - fi - - echo -e "${GREEN}[✓] [$FILE] Crontab confirmed.${NC}" + echo -e "${LIGHT_BLUE}[i] [$FILE] Crontab already exists. Removing...${NC}" + crontab -l | grep -v $FILE | crontab - fi + echo -e "${LIGHT_BLUE}[i] [$FILE] Adding crontab...${NC}" + + if [ "$FILE" == "clean.sh" ]; then + (crontab -l 2>/dev/null; echo "0 0 * * * ${CURRENT_WORKDIR}/$FILE > /tmp/clean.log") | crontab - + elif [ "$FILE" == "backup.sh" ]; then + (crontab -l 2>/dev/null; echo "0 0 * * * ${CURRENT_WORKDIR}/$FILE > /tmp/backup.log") | crontab - + elif [ "$FILE" == "docker-updater.sh" ]; then + (crontab -l 2>/dev/null; echo "0 3 */4 * * ${CURRENT_WORKDIR}/$FILE > /tmp/docker-updater.log") | crontab - + else + echo -e "${YELLOW}[w] [$FILE] Warning: Crontab specific schedule not setup.${NC}" >&2 + (crontab -l 2>/dev/null; echo "0 0 * * * ${CURRENT_WORKDIR}/$FILE" > /tmp/$FILE.log) | crontab - + fi + + echo -e "${GREEN}[✓] [$FILE] Crontab added, double-checking set up...${NC}" + + if ! crontab -l | grep -q $FILE; then + echo -e "${RED}[x] [$FILE] Error: Crontab was not set up.${NC}" >&2 + exit 1 + fi + + echo -e "${GREEN}[✓] [$FILE] Crontab confirmed.${NC}" done echo -e "${GREEN}[✓] Crontabs all set up.${NC}"