feat: add hourly rolling logs

This commit is contained in:
Tim
2025-08-04 12:51:16 +08:00
parent ee0aceeab7
commit afe01bc6ad
4 changed files with 45 additions and 1 deletions

12
backend/scripts/extract_logs.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/usr/bin/env bash
# Extract gzipped logs from the last three days into a target directory.
# Usage: ./extract_logs.sh [output_dir]
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
LOG_DIR="${SCRIPT_DIR}/../logs"
OUTPUT_DIR="${1:-${SCRIPT_DIR}/extracted}"
mkdir -p "$OUTPUT_DIR"
find "$LOG_DIR" -name 'application-*.log.gz' -mtime -3 -print \
-exec sh -c 'gzip -dc "$1" > "$2/$(basename "$1" .gz)"' _ {} "$OUTPUT_DIR" \;
echo "Logs extracted to $OUTPUT_DIR"