ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 每5秒监控5000端口的shell脚本

每5秒监控5000端口的shell脚本

原创 Linux操作系统 作者:abin1703 时间:2016-09-14 13:37:16 0 删除 编辑
#!/bin/bash
while true;do
echo "************************************************************"
date
# ================================================================


TCPListeningnum=`netstat -an | grep ":5000" | awk '$1 == "tcp" && $NF == "LISTEN" {print $0}' | wc -l`
if [ $TCPListeningnum -eq 0 ]
then
{
echo "listener port is down">>/root/1.log
#如果5000端口down了,重启tomcat服务
cd /Smaritbi/apache-tomcat-7.0.34/bin/
./shutdown.sh
./start.sh
}
else
{
echo "5000端口正常" >>/root/l.log
date
}
fi
sleep 5;
done
~        

执行该脚本
nohup sh 1.sh > /dev/null 2>&1&

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30345407/viewspace-2124973/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: linux GPT命令大全
请登录后发表评论 登录
全部评论

注册时间:2015-07-13

  • 博文量
    204
  • 访问量
    426805