现在的位置: 首页 > Linux > shell脚本 > 正文
判断服务是否运行的shell脚本
2013年03月18日 shell脚本 ⁄ 共 198字 判断服务是否运行的shell脚本已关闭评论 ⁄ 被围观 18,136 views+

用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

抱歉!评论已关闭.

×