- #!/bin/bash
-
- #截取httped进程,并把结果赋予变量test
- test=$(ps -aux | grep "httpd" | grep -v "grep")
-
- #如果test的值不为空,则执行then中命令
- if [ -n $"test" ]
- then
- echo "$(date) httped is ok!" >> /tmp/autostart-acc.log
- else
- /etc/rc.d/init.d/httpd start &> /dev/null
- echo "$(date) restart httpd !" >> /tmp/autostart-err.log
- fi
Shell双分支if语句(2)- 判断Apache服务是否启动