linux 监视端口是否正常的shell脚本
程序员文章站
2023-09-28 10:09:03
复制代码 代码如下: #!/bin/bash port=”80″ restart=”/etc/init.d/httpd restart” email=”/bin/echo...
复制代码 代码如下:
#!/bin/bash
port=”80″
restart=”/etc/init.d/httpd restart”
email=”/bin/echo selboo | mutt -s "重新启动httpd" root@selboo.com.cn”
netstat -ln |awk ‘/^tcp/ {print $4}' |grep -q “:$port$” || {
#reboot httpd
eval $restart;$email
exit $?
}
exit 0