#!/bin/sh
#
ORACLE_USER=oracle
TMP_FILE="/tmp/lsnrcmd"
###############
# use Yes or Y ,NO or N
ROTATE_FILE=y
###############
ROTATE=3
###########################################
EXEC_USER=`who -m |awk '{print $1}'`
CLEAN_LOG(){
if [ $EXEC_USER = "root" ]; then
su - $ORACLE_USER -c $ORACLE_HOME/bin/lsnrctl < $TMP_FILE
elif [ $EXEC_USER = "$ORACLE_USER" ]; then
$ORACLE_HOME/bin/lsnrctl < $TMP_FILE
fi
}
ROTATE_LOG(){
if [ -e /tmp/lsntmp ] ; then
NUM=`cat /tmp/lsntmp`
if [ $ROTATE -eq $NUM ] ;then
NUM="0"
echo $NUM > /tmp/lsntmp
else
NUM=`echo "$NUM + 1" |bc`
echo $NUM > /tmp/lsntmp
fi
else
echo "0" > /tmp/lsntmp
NUM="0"
fi
}
case $ROTATE_FILE in
[Nn]|[Nn][Oo])
echo "set current_listener LISTENER" > $TMP_FILE
echo "set log_file listener" >> $TMP_FILE
echo "exit" >> $TMP_FILE
CLEAN_LOG
;;
[Yy]|[Yy][Ee][Ss])
ROTATE_LOG
echo "set current_listener LISTENER" > $TMP_FILE
echo "set log_file listener.$NUM" >> $TMP_FILE
echo "exit" >> $TMP_FILE
CLEAN_LOG
;;
esac
張貼留言