转载

日志管理程序

#!/bin/bash
#author: Rui Zhang
#date: 2017-09-22
#email: sharpzhang_2008@126.com


function restore_log(){


tday_num=`date +'%F-%s'`


dir_name=$1


log_name=$2


cd $dir_name 
#pwd


echo dir_name:$dir_name


echo log_name:$log_name


#cp $log_name $tday_num
echo restored_name:$tday_num'_'$log_name


cp $log_name $tday_num'_'$log_name


echo > $log_name
}






function clear_log(){


dir_name=$1
log_name=$2




cd $dir_name 




echo dir_name:$dir_name


echo postfix_name:$log_name


echo keywords:"*.${log_name}"






#find $dir_name -mtime +90 -name "*.${log_name}"


find $dir_name -mtime +7 -name "*.${log_name}" |wc -l


find $dir_name -mtime +7 -name "*.${log_name}" -exec rm -f {} /;




find $dir_name -mtime +7 -name "*.${log_name}" |wc -l


}


echo ''
echo '1. restore_log:'
echo ''


echo '#######################listener_log#######################################'


restore_log /u01/app/oracle/diag/tnslsnr/zhangr/listener/trace/ listener.log


echo '#######################scan_listener_log##################################'


restore_log /u01/app/11.2.0/grid/log/diag/tnslsnr/zhangr/listener_scan1/trace/ listener_scan1.log


echo ''
echo '2.clear_log:'
echo ''


echo '#######################aud_log##########################################'


clear_log /u01/app/oracle/admin/test/adump/ aud


echo '#######################trc_log##########################################'


clear_log /u01/app/oracle/diag/asm/+asm/+ASM1/trace trc


echo '#######################trm_log##########################################'


clear_log /u01/app/oracle/diag/asm/+asm/+ASM1/trace trm
正文到此结束
Loading...