Hello, blightmud-batmud-logger
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
#!/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."
|
||||
Reference in New Issue
Block a user