【发布时间】:2015-11-17 09:06:46
【问题描述】:
编写了一个简单的 bash 脚本,该脚本将运行以检查我的 Centos 服务器上是否正在运行 httpd (apache) 或 clamd (antivirus),如果没有,它将重新启动它们。
#!/bin/bash
if [[ ! "$(/sbin/service httpd status)" =~ "running" ]]
then
service httpd start
elif [[ ! "$(/sbin/service clamd status)" =~ "running" ]]
then
service clamd start
fi
通过命令行对其进行了测试,所以它可以工作,但是有什么方法可以进一步优化吗?
【问题讨论】: