Linux,shell脚本查看本机Apache存活情况

#!/bin/bash
lsof -i:80 > /dev/null
if [ $? -eq 0 ]; then
echo "UP"
exit "0"
else
echo "DOWN"
exit "2"
fi

 

[root@b opt]# vim httpd.sh
[root@b opt]#/etc/init.d/httpd start
[root@b opt]# ./httpd.sh
0
[root@b opt]#/etc/init.d/httpd stop
[root@b opt]# ./httpd.sh
2

posted @ 2018-07-11 14:57  邪道祖师  阅读(143)  评论(0编辑  收藏  举报