#! /bin/ksh #set -x ################################################################################################# # # # Script: /home/oracle/scripts/purge_em10g_logs.sh # # # # Purpose: Purge OMS logs files older than x number of days on an EM10g installation. # # # # NOTE: Restart of the OMS required! ...not ideal, but did the job at the time :) # # # # Typical cron entry (midnight, every Sunday): # # 0 0 * * 0 /purge_em10g_logs.sh > /purge_em10g_logs.out # # # # Change Log: 03/08/2009 GH Initial Release # # 11/07/2013 GH Tidied up # # # ################################################################################################# ############################# # Set environment variables # ############################# export PURGE_AGE=15 export MW_HOME=/u01/app/oracle/middleware export OMS_HOME=$MW_HOME/oms10g ################## # Start clean up # ################## echo "FS space check before purge..." #df -g $OMS_HOME df -h $OMS_HOME ##################### # Purge Apache logs # ##################### echo echo "Purge Apache logs..." cd ${OMS_HOME}/Apache/Apache/logs tail -1000 access_log > access_log.1000 tail -1000 error_log > error_log.1000 cat /dev/null > access_log cat /dev/null > error_log ################### # Purge OC4J logs # ################### echo "Purge OC4J logs..." cd ${OMS_HOME}/j2ee/OC4J_EM/log/OC4J_EM_default_island_* tail -1000 em-application.log > em-application.log.1000 tail -1000 default-web-access.log > default-web-access.log.1000 tail -1000 server.log > server.log.1000 cat /dev/null > em-application.log cat /dev/null > default-web-access.log cat /dev/null > server.log ############### # Restart OMS # ############### echo "Restarting OMS services..." ${OMS_HOME}/opmn/bin/opmnctl stopall sleep 5 ${OMS_HOME}/opmn/bin/opmnctl startall ${OMS_HOME}/opmn/bin/opmnctl status echo echo "FS space check after purge..." #df -g $OMS_HOME df -h $OMS_HOME ################# # End of Script # #################