#!/bin/sh
#user wyyue
#date 2018-12-02
#version redis:4.0.11 V1
. /etc/init.d/functions
port=6380
ipaddr=10.0.0.98
server=/usr/local/redis6380/redis-server
conf=/usr/local/redis6380/redis.conf
custom=/usr/local/redis-4.0.11/src/redis-cli
pidfile=/var/run/redis_6380.pid
public(){
while [ -x /proc/$pid ]
do
echo "redis is stopping..."
sleep 1
done
action "redis stopped" /bin/true
}
start_redis(){
if [ -f $pidfile ];then
action "redis is already running" /bin/true
else
$server $conf
if [ $? -eq 0 ];then
action "redis start success" /bin/true
else
action "redis start fail" /bin/false
fi
fi
}
stop_redis(){
if [ ! -f $pidfile ];then
action "redis is already stoped" /bin/true
else
pid=$(cat $pidfile)//获得proc下对应的值pid
passwd=`grep 'requirepass' /usr/local/redis6380/redis.conf|awk '{print $2}'|sed 's#"##g'` //获取requirepass的值即密码
if [ -z $passwd ];then
$custom -h $ipaddr -p $port shutdown //没有密码
public
else
$custom -h $ipaddr -p $port -a $passwd shutdown //有密码要授权
public
fi
fi
}
status_redis(){
if [ -f $pidfile ];then
action "redis is running " /bin/true
else
action "redis is stopped" /bin/false
fi
}
restart_redis(){
stop_redis
sleep 3
start_redis
}
case "$1" in
start)
start_redis
;;
stop)
stop_redis
;;
restart)
restart_redis
;;
status)
status_redis
;;
*)
echo "USAGE:$0{start|stop|status|restart}"
;;
esac
redis的启动脚本
原创
©著作权归作者所有:来自51CTO博客作者zbjtwyyue的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:DoS攻击_详解(转载)
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
jenkins通过脚本启动java应用
本文简单简单介绍怎么通过jenkins来调用shell脚本启动java脚本。
html/xml shell