[root@db01-51 scripts]# cat check_web.sh #!/bin/bash if [ `curl -I www.baidu.com 2>/dev/null|head -1|egrep "200|302|301"|wc -l` -eq 1 ] then echo "httpd is running" else echo "httpd is stopped" fi