#!/bin/bash
#place the alter.log and listener.log on file monthly
#get the last month date
last_month=`date -d last-month +%Y%m`
#alter.log
cd $ORACLE_BASE/admin/${ORACLE_SID}/bdump
mv alert_$ORACLE_SID.log alert_$ORACLE_SID_$last_month.log
#listener log
cd $ORACLE_HOME/network/log
lsnrctl set log_status off
mv listener.log listener_$last_month.log
lsnrctl set log_status on
需要设置好$ORACLE_BASE,$ORACLE_HOME,$ORACLE_SID这个三个基本的环境变量,脚本里面懒得判断了