shell习题6 题: 监控http80端口,发现服务down了之后,启动程序 #!/bin/bash while : do http=`netstat -ntlp|grep 80|grep http|wc -l` if [ $http -eq 0 ];then echo "http server is down" >> error.txt systemctl start httpd else sleep 60 fi done