Easy-to-use Redis startup management scripts that need to be adapted to the Redis-related files you install
I am the source of the installation of redis-3.0.5
Installation path/usr/local/redis
To edit the Create script file:
Vim/etc/init.d/redis
#!/bin/sh## chkconfig: 2345 85 15 # description: this script can manager the redis-server daemon# Redis is a persistent key-value database# exec: /usr/local/redis/bin/redis-server# config: /usr/local/redis/conf/redis.conf # pidfile: /usr/local/redis/logs/redis.pid # datafile: / usr/local/redis/data/redis.rdb redis= "/usr/local/redis/bin/redis-server" REDIS_CONF_FILE= "/usr/local /redis/conf/redis.conf "prog=$ (basename $redis) lockfile=/var/lock/subsys/redis# source function library. /etc/rc.d/init.d/functions # source networking configuration. /etc/sysconfig/network # check that networking is up. [ "$NETWORKING" = "No" ] && exit 0 start () { [ -x $redis ] | | exit 5 [ -f $REDIS _conf_file ] | | exit 6 echo -n $ "starting $prog: " daemon $redis $REDIS _conf_file retval=$? echo [ $retval -eq 0 ] && touch $lockfile return $retval}stop () { echo -n $ "stopping $ prog: " killproc $prog -QUIT retval=$? echo [ $retval  -EQ 0 ] && RM -f $lockfile     RETURN  $retval}restart () { stop start}reload () { echo -n $ "reloading $prog: " killproc $redis -hup retval=$? echo}rh_status () { status $prog}rh_status_q () { rh_status >/dev/null 2> &1}case "$" in start) rh_ status_q && exit 0 $1 ;; stop) rh_status_q | | exit 0 $1 ;; restart) $1 ;; reload) rh_status_q | | exit 7 $1 ;; status) rh_status ;; *) echo $ "Usage: $0 { Start|stop|restart|reload|status} " exit 2esac
Modify script action permissions, add executable permissions
chmod 755/etc/init.d/redis
##### END #####
This article is from the "Qin Notes" blog, please be sure to keep this source http://ciqin.blog.51cto.com/10608412/1794671
Redis Startup Management Scripts