您现在的位置是:网站首页> 编程资料编程资料

linux 监视端口是否正常的shell脚本_linux shell_

2023-05-26 351人已围观

简介 linux 监视端口是否正常的shell脚本_linux shell_

复制代码 代码如下:

#!/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

-六神源码网