脚本代码如下:
#!/bin/bash
. /home/oracle/.bash_profile
tempfile=/oracle/admin/$ORACLE_SID/tempfile.lis
lsnrctl status > $tempfile
if [ $?!=0 ]
then
echo " " >> $tempfile
echo "=============================================" >> $tempfile
echo " " >> $tempfile
date >> $tempfile
echo "Listener is down, restarting it agin." >> $tempfile
lsnrctl start >> $tempfile
if [ $?=0 ]
then
mail zgk_baqi@126.com -s "Listener is restarted." < $tempfile
else
mail zgk_baqi@126.com -s "Listener is down, restarting failed." < $tempfile
fi
fi
rm -f $tempfile