脚本之家,脚本语言编程技术及教程分享平台!
分类导航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|shell|

服务器之家 - 脚本之家 - shell - linux 监视端口是否正常的shell脚本

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

2022-12-08 11:09shell教程网 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

延伸 · 阅读

精彩推荐