function is_running()
{
s=`ps -ef|grep $1|wc -l`
echo ${s}
if [ ${s} -gt 1 ];then
echo "$1 is running"
else
list=`chkconfig --list|grep $2|wc -l`
if [ ${list} -eq 0 ];then
chkconfig --add $2
chkconfig --level 35 $2 on
else
/etc/init.d/$2 start
is_running $1 $2
fi
fi

}

is_running redis redis

验证redis是否运行,如果没运行,则运行

判断redis是否在服务列表,如果没有,则添加

判断redis是否添加至自启动,如果没有,则添加