tnsping listener
if return code isthen
do nothing and tnsping the listener later.
else
do a PS and grep for tnslsnr PID
kill -9 listener_pid
lsnrctl start
resume cron job
end.
上面 是假的 代码写个SHELL脚本
针对aix 4.3
. $HOME/orashell
if [ -f /oracleplus/lsncheck.lst ]; then
rm /oracleplus/lsncheck.lst;
fi
echo checking listener start time : `date` > /oracleplus/lsncheck.lst
`tnsping $oraplus | grep OK >> /oracleplus/lsncheck.lst &`
#其中,上面的$oraplus需要你定義自己的聯接串。
sleep 3
test `cut -c1,2 /oracleplus/lsncheck.lst | grep OK`
if (($? != 0)); then
pid=`ps -ef | grep -v grep | grep tnslsnr | awk '{print $2}'`
if [ "X$pid" != "X" ]; then
if kill $pid; then
echo kill tnslsnr successfully !!
else
echo kill tnslsnr failed !!
fi
fi
lsnrctl start
else
echo listener is OK !!
fi
exit