25 lines
672 B
Bash
25 lines
672 B
Bash
#!/usr/bin/env sh
|
|
# Compress all .log files not modified today across all character subdirs.
|
|
# Expects /logs to be mounted from the host.
|
|
|
|
LOG_DIR="${LOG_DIR:-/logs}"
|
|
TODAY=$(date +%Y-%m-%d)
|
|
|
|
find "$LOG_DIR" -maxdepth 2 -name "*.log" | while read -r f; do
|
|
FILE_DATE=$(date -r "$f" +%Y-%m-%d 2>/dev/null)
|
|
|
|
if [ "$FILE_DATE" = "$TODAY" ]; then
|
|
echo "[$(date +%H:%M:%S)] Skipping active log: $f"
|
|
continue
|
|
fi
|
|
|
|
echo "[$(date +%H:%M:%S)] Compressing: $f"
|
|
if zstd -19 --rm -q "$f"; then
|
|
echo "[$(date +%H:%M:%S)] Done: ${f}.zst"
|
|
else
|
|
echo "[$(date +%H:%M:%S)] ERROR compressing: $f" >&2
|
|
fi
|
|
done
|
|
|
|
echo "[$(date +%H:%M:%S)] Compression run complete."
|