aktualizace skriptu
This commit is contained in:
parent
cd642db943
commit
136ca6e660
@ -1,19 +1,21 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Nastavení proměnných
|
# Nastavení proměnných
|
||||||
LOG_DIR="/path/to/your/logs"
|
LOG_DIR="/path/to/your/log"
|
||||||
LOG_FILE="/path/to/your/logs/clean_logs.log"
|
LOG_FILES=("sync_gitea_to_github.log" "clean_logs.log")
|
||||||
DAYS_TO_KEEP=30
|
|
||||||
|
|
||||||
# Přepsání log souboru
|
# Přepsání log souboru pro diagnostiku
|
||||||
echo "Starting log cleanup at $(date)" > $LOG_FILE
|
echo "Starting log cleanup at $(date)"
|
||||||
|
|
||||||
# Vyčištění log souborů starších než zadaný počet dní
|
# Smazání a znovuvytvoření log souborů
|
||||||
find $LOG_DIR -type f -name "*.log" -mtime +$DAYS_TO_KEEP -exec rm -f {} \; >> $LOG_FILE 2>&1
|
for LOG_FILE in "${LOG_FILES[@]}"; do
|
||||||
|
if [ -f "$LOG_DIR/$LOG_FILE" ]; then
|
||||||
|
rm "$LOG_DIR/$LOG_FILE"
|
||||||
|
echo "Deleted $LOG_FILE"
|
||||||
|
fi
|
||||||
|
touch "$LOG_DIR/$LOG_FILE"
|
||||||
|
echo "Created new $LOG_FILE"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Log cleanup completed successfully at $(date)"
|
||||||
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
echo "Log cleanup completed successfully at $(date)" >> $LOG_FILE
|
|
||||||
else
|
|
||||||
echo "Error: Log cleanup failed at $(date)" >> $LOG_FILE
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
Loading…
Reference in New Issue
Block a user