clean up log files with ANSI color codes

This commit is contained in:
Peter Wood
2025-06-23 06:00:55 -04:00
parent 70755e5823
commit b04c93daf2
4 changed files with 573 additions and 1 deletions

View File

@@ -29,7 +29,7 @@ log_message() {
local message="$1"
local log_file="$LOG_DIR/crontab-management.log"
echo -e "$(date '+%Y-%m-%d %H:%M:%S') $message"
echo "$(date '+%Y-%m-%d %H:%M:%S') $message" | sed 's/\x1b\[[0-9;]*m//g' >> "$log_file"
echo "$(date '+%Y-%m-%d %H:%M:%S') $message" | sed 's/\\033\[[0-9;]*m//g' >> "$log_file"
}
log_error() {

View File

@@ -39,6 +39,10 @@
# Validates integrity of .env backup repository
30 8 * * 0 { echo "Starting .env backup validation"; /home/acedanger/shell/validate-env-backups.sh; echo ".env validation completed with exit code: $?"; } 2>&1 | logger -t env-validation -p user.info
# Weekly log files ANSI cleanup (Sundays at 0900)
# Removes ANSI color codes from log files to improve readability and reduce size
0 9 * * 0 { echo "Starting log ANSI cleanup"; /home/acedanger/shell/cleanup-log-ansi.sh --auto-discover --backup >/dev/null; echo "Log cleanup completed with exit code: $?"; } 2>&1 | logger -t log-cleanup -p user.info
# Optional: Add a health check entry to monitor cron jobs (every 6 hours)
# This can help detect if any of the backup processes are failing
# 0 */6 * * * { echo "Cron health check - all backup jobs scheduled"; ps aux | grep -E "(backup-plex|validate-plex|move-backups)" | grep -v grep | wc -l; } 2>&1 | logger -t cron-health -p user.info