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"

Comments

Popular posts from this blog

fix pack installation on websphere using command line (imcl)

HMGR0152W: CPU Starvation detected messages in SystemOut.log

How to diagnose error "SRVE0255E: A WebGroup/Virtual Host to handle {0} has not been defined"