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

猜你喜欢

转载自www.cnblogs.com/nwpLinux/p/9294485.html
今日推荐