Shell双分支if语句(2)- 判断Apache服务是否启动
时间:2021-08-07 17:08:55
收藏:0
阅读:19
- #!/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
原文:https://www.cnblogs.com/gltou/p/15111735.html
评论(0)