Showing posts with label Logs. Show all posts
Showing posts with label Logs. Show all posts

Sunday, February 8, 2015

Useful Scripts

Following script is used to clean up the logs by executing the script with 2 parameters (domain name & server name)

cleanLogs.sh

#!/bin/ksh

usage()
{
 echo "\n!!!!!Usage!!!!!!!"
 echo
 echo " cleanLogs.sh "
 echo "\ne.g. cleanLogs.sh mydomain myServer"
 echo
}
if [ $# -ne 2 ]
then
 usage
 exit 2
fi

domain=$1
server=$2
FMW_HOME=/opt/fmw/

#Remove the logs older than 30 days
find $FMW_HOME/user_projects/domains/${domain}/servers/${server}/logs/*_log.* -mtime +30 | xargs rm

#Compress the logs older than 15 days
find $FMW_HOME/user_projects/domains/${domain}/servers/${server}/logs/*access_log.* -mtime +15 | xargs compress

exit