以下两个脚本都是可以的,但是前提是脚本保存的文本的名称不能含有lsnr,因为ps -ef|grep lsnr|grep -v grep匹配了脚本名字
#!/bin/ksh
ps -ef|grep lsnr|grep -v grep>/dev/null
if [ $? -eq 0 ]; then
exit
else
echo `date`>/tmp/dsklog.lsnrctl
echo " The listener is down on 10.98.20.122">>/tmp/dsklog.lsnrctl
lsnrctl start>>/tmp/dsklog.lsnrctl
cat /tmp/dsklog.lsnrctl | /usr/local/bin/mailx -s "listener on 10.98.20.122 is down" luk.luk@chinadba.cn
fi
#!/bin/ksh
lsnr_flag=`ps -ef|grep lsnr|grep -v grep`
if [ -z "$lsnr_flag" ]; then
echo `date`>/tmp/dsklog.lsnrctl
echo " The listener is down on 10.98.20.122">>/tmp/dsklog.lsnrctl
lsnrctl start>>/tmp/dsklog.lsnrctl
cat /tmp/dsklog.lsnrctl | /usr/local/bin/mailx -s "listener on 10.98.20.122 is down" luk.luk@chinadba.cn
fi
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30126024/viewspace-2139885/
,如需转载,请注明出处,否则将追究法律责任。