Redis Open-Start (Centos) under Linux
1
1VI /etc/init.d/redis
2 script contents are as follows:
# Chkconfig:2345 Ten -# Description:start and Stop Redis PATH=/usr/local/bin:/sbin:/usr/bin:/bin Redisport=6379EXEC=/usr/redisbin/redis-Server Redis_cli=/usr/redisbin/redis-CLI Pidfile=/var/run/redis.pid CONF="/usr/redisbin/redis.conf"AUTH="1234" Case " $" inchstart)if[ -F $PIDFILE] Then Echo "$PIDFILE exists, process is already running or crashed." Else Echo "starting Redis Server ..."$EXEC $CONFfi if["$?"="0" ] Then Echo "Redis is running ..." fi ;; Stop)if[ ! -F $PIDFILE] Then Echo "$PIDFILE exists, process is not running." ElsePID=$(Cat$PIDFILE)Echo "stopping ..."$REDIS _cli-P $REDISPORT SHUTDOWNSleep 2 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}">&2Exit1 Esac
4. Set permissions
chmod 755 Redis
55. Start Test
/etc/init.d/redis start
6. Set Boot from boot
Chkconfig Redis on
Linux set Boot execution command script