#! /bin/ksh #set -x ################################################################################################# # # # Script: /home/oracle/scripts/purge_em11g_logs.sh # # # # Purpose: Purge OMS logs files older than x number of days on an EM11g installation. # # # # This can be used on additional OMS installations, but the Admin Server only runs # # from the primary OMS machine, so no EMGC_ADMINSERVER logs will be found. # # # # Typical cron entry (midnight, every Sunday): # # 0 0 * * 0 /purge_em11g_logs.sh > /purge_em11g_logs.out # # # # Change Log: 13/04/2011 GH Initial Release # # 11/07/2013 GH Tidied up # # # ################################################################################################# ############################# # Set environment variables # ############################# export PURGE_AGE=15 export MW_HOME=/u01/app/oracle/middleware export EM_INST_HOME=$MW_HOME/gc_inst export AGENT_HOME=$MW_HOME/agent11g ################## # Start clean up # ################## echo "FS space check before purge..." #df -g $EM_INST_HOME df -h $EM_INST_HOME ####################################### # Purge Oracle HTTP Server (OHS) logs # ####################################### echo echo "Purge Oracle HTTP Server (OHS) logs..." #cd ${EM_INST_HOME}/WebTierIH1/diagnostics/logs/OHS/ohs1 cd ${EM_INST_HOME}/WebTierIH*/diagnostics/logs/OHS/ohs* find . \( ! -name . -prune \) -name "access_log.*" -mtime +${PURGE_AGE} -exec rm {} \; find . \( ! -name . -prune \) -name "em_upload_https_access_log.*" -mtime +${PURGE_AGE} -exec rm {} \; find . \( ! -name . -prune \) -name "em_upload_http_access_log.*" -mtime +${PURGE_AGE} -exec rm {} \; find . \( ! -name . -prune \) -name "ohs1-*.log" -mtime +${PURGE_AGE} -exec rm {} \; # Note: to configure log rotation of the mod_wl_ohs files, check MOS note 1271676.1 find . \( ! -name . -prune \) -name "mod_wl_ohs*.log" -mtime +${PURGE_AGE} -exec rm {} \; ################################################################ # Purge WLS Admin Server logs (only applicable to primary OMS) # ################################################################ echo "Purge WLS Admin Server logs..." cd ${EM_INST_HOME}/user_projects/domains/GCDomain/servers/EMGC_ADMINSERVER/logs find . \( ! -name . -prune \) -name "EMGC_ADMINSERVER.out0*" -mtime +${PURGE_AGE} -exec rm {} \; find . \( ! -name . -prune \) -name "EMGC_ADMINSERVER.log0*" -mtime +${AGE} -exec rm -ef {} \; ############################# # Purge WLS OMS Server logs # ############################# echo "Purge WLS OMS Server logs..." cd ${EM_INST_HOME}/user_projects/domains/GCDomain/servers/EMGC_OMS*/logs find . \( ! -name . -prune \) -name "access.log0*" -mtime +${PURGE_AGE} -exec rm {} \; find . \( ! -name . -prune \) -name "EMGC_OMS*.out0*" -mtime +${PURGE_AGE} -exec rm {} \; find . \( ! -name . -prune \) -name "EMGC_OMS*.log0*" -mtime +${PURGE_AGE} -exec rm {} \; find . \( ! -name . -prune \) -name "GCDomain.log0*" -mtime +${PURGE_AGE} -exec rm {} \; find . \( ! -name . -prune \) -name "EMGC_OMS*-diagnostic-*.log" -mtime +${PURGE_AGE} -exec rm {} \; ########################### # Purge Agent SYSMAN logs # ########################### echo "Purge Agent SYSMAN logs..." cd ${AGENT_HOME}/sysman/log find . \( ! -name . -prune \) -name "emagent.log.*" -mtime +${PURGE_AGE} -exec rm {} \; find . \( ! -name . -prune \) -name "emagent.trc.*" -mtime +${PURGE_AGE} -exec rm {} \; ######################################## # Other directories to look out for... # ######################################## #/home/oracle/oradiag_oracle/diag/clients/user_oracle/host_*/alert #/home/oracle/oradiag_oracle/diag/clients/user_oracle/host_*/trace echo echo "FS space check after purge..." #df -g $EM_INST_HOME df -h $EM_INST_HOME ################# # End of Script # #################