Redis启动脚本,开机自动启动
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Redis启动脚本,开机自动启动相关的知识,希望对你有一定的参考价值。
# chkconfig: 2345 90 10
# description: Redis is a persistent key-value database
PATH=$PATH:/usr/local/redis/bin:/sbin:/usr/bin:/bin
REDISPORT=6379
EXEC=/usr/local/redis/bin/redis-server
REDIS_CLI=/usr/local/redis/bin/redis-cli
PASS=chbin123
PIDFILE=/var/run/redis_6379.pid
CONF="/usr/local/redis/etc/redis.conf"
case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis server..."
$EXEC $CONF
fi
if [ "$?"="0" ]
then
echo "Redis is running..."
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$REDIS_CLI -a $PASS -p $REDISPORT SHUTDOWN
while [ -x ${PIDFILE} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
restart|force-reload)
${0} stop
${0} start
;;
*)
echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2
exit 1
esac
-----------------------------
添加redis服务开机启动:
chmod +x /etc/init.d/redis
启动redis服务:
service redis start
检查服务是否启动
ps -ef | grep redis
netstat -anptu | grep 6379
本文出自 “無言的对白” 博客,请务必保留此出处http://chbinmile.blog.51cto.com/6085145/1912643
以上是关于Redis启动脚本,开机自动启动的主要内容,如果未能解决你的问题,请参考以下文章