Wikipedia
Search results
Sunday, 26 May 2024
Script for WebSphere Log Housekeeping
#!/bin/bash
# Configuration
LOG_DIR="/path/to/websphere/logs" # Directory where logs are stored
ARCHIVE_DIR="/path/to/websphere/archive" # Directory to move compressed logs
DAYS_TO_KEEP=30 # Number of days to keep logs before deletion
LOG_EXTENSION="log" # Log file extension (e.g., log, out)
# Create archive directory if it doesn't exist
mkdir -p "$ARCHIVE_DIR"
# Find and compress log files older than $DAYS_TO_KEEP days
find "$LOG_DIR" -name "*.$LOG_EXTENSION" -type f -mtime +$DAYS_TO_KEEP -exec gzip {} \; -exec mv {}.gz "$ARCHIVE_DIR" \;
# Delete compressed log files older than $DAYS_TO_KEEP days from the archive directory
find "$ARCHIVE_DIR" -name "*.$LOG_EXTENSION.gz" -type f -mtime +$DAYS_TO_KEEP -exec rm -f {} \;
# Log the housekeeping activity
echo "$(date +'%Y-%m-%d %H:%M:%S') - WebSphere log housekeeping completed" >> "$LOG_DIR/housekeeping.log"
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment