#!/bin/sh# chkconfig: 2345 90 10## Simple Redis init.d script conceived to work on Linux systems# as it does use of the /proc filesystem.#redis服务器监听的端口
REDISPORT=6379
#服务端所处位置
EXEC=/usr/bin/redis-server
#客户端位置
CLIEXEC=/usr/bin/redis-cli#redis的PID文件位置,需要修改为自己文件位置
PIDFILE=/var/run/redis/redis-server.pid
#redis的配置文件位置,需要修改为自己文件位置
CONF="/etc/redis/redis.conf"
case "$1" in
start)if[-f $PIDFILE]
then
echo"$PIDFILE exists, process is already running or crashed"elseecho"Starting Redis server..."$EXEC$CONF
fi
;;
stop)if[!-f $PIDFILE]
then
echo"$PIDFILE does not exist, process is not running"else
PID=$(cat$PIDFILE)echo"Stopping ..."$CLIEXEC-p $REDISPORT shutdown
while[-x /proc/${PID}]doecho"Waiting for Redis to shutdown ..."sleep 1
done
echo"Redis stopped"
fi
;;*)echo"Please use start or stop as first argument";;
esac
1.编辑启动脚本到/etc/init.d目录下,本例将启动脚本命名为redisd(通常都以d结尾表示是后台自启动服务)vim /etc/init.d/redisd#!/bin/sh# chkconfig: 2345 90 10## Simple Redis init.d script conceived to work on Linux systems# as it does u...