mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-28 00:50:46 +08:00
feat: add hourly rolling logs
This commit is contained in:
12
backend/scripts/extract_logs.sh
Executable file
12
backend/scripts/extract_logs.sh
Executable 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"
|
||||
Reference in New Issue
Block a user