fixing crontab again phew
All checks were successful
Check scripts syntax / check-scripts-syntax (push) Successful in 35s

This commit is contained in:
Jose Henrique 2025-01-06 21:07:46 -03:00
parent 97010d71ff
commit b54222eb23

View File

@ -146,19 +146,20 @@ 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] 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 > /dev/null") | crontab -
(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 > /dev/null") | crontab -
(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 > /dev/null") | crontab -
(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" > /dev/null) | crontab -
(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}"
@ -169,7 +170,6 @@ for FILE in "${FILES[@]}"; do
fi
echo -e "${GREEN}[✓] [$FILE] Crontab confirmed.${NC}"
fi
done
echo -e "${GREEN}[✓] Crontabs all set up.${NC}"