用pgrep命令判斷
#!/bin/bash
##作用:檢測服務是否啟動,服務以參數方式提交
##作者:Barlow ##
##時間:2013-3-18 ##
ser=`/usr/bin/pgrep $1`
if [ "$ser" != "" ]
then
echo "The $1 service is running."
else
echo "The $1 service is NOT running."
/sbin/service $1 start
fi