Wikipedia
Search results
Sunday, 26 May 2024
Was Patching
#!/bin/bash
# Configuration
WAS_HOME="/opt/IBM/WebSphere/AppServer" # WebSphere home directory
PROFILE_NAME="AppSrv01" # WebSphere profile name
IMCL_PATH="/opt/IBM/InstallationManager/eclipse/tools/imcl" # Installation Manager CLI path
REPOSITORY_PATH="/path/to/repository" # Path to the repository containing the patches
LOG_DIR="$WAS_HOME/logs/patching" # Directory to store patch logs
PATCHES="com.ibm.websphere.ND.v85_8.5.5.15" # Patch ID(s)
# Create log directory if it doesn't exist
mkdir -p "$LOG_DIR"
# Stop the server
echo "Stopping WebSphere server..."
"$WAS_HOME/profiles/$PROFILE_NAME/bin/stopServer.sh" server1
if [ $? -ne 0 ]; then
echo "Failed to stop WebSphere server. Exiting."
exit 1
fi
# Apply the patch
echo "Applying WebSphere patch..."
"$IMCL_PATH" install "$PATCHES" -repositories "$REPOSITORY_PATH" -installationDirectory "$WAS_HOME" -log "$LOG_DIR/patching_$(date +'%Y%m%d%H%M%S').log" -acceptLicense
if [ $? -ne 0 ]; then
echo "Failed to apply WebSphere patch. Exiting."
exit 1
fi
# Start the server
echo "Starting WebSphere server..."
"$WAS_HOME/profiles/$PROFILE_NAME/bin/startServer.sh" server1
if [ $? -ne 0 ]; then
echo "Failed to start WebSphere server. Exiting."
exit 1
fi
echo "WebSphere patching completed successfully."
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:
Posts (Atom)