将redis添加到linux系统服务

(1)

[root@xiaofeibao ~]# find / -name redis
/etc/redis
/etc/logrotate.d/redis
/etc/rc.d/init.d/redis
/swoole-1.9.6/examples/redis
/var/log/redis
/var/run/redis
/var/lib/redis

(2)参考链接

http://blog.csdn.net/justfor3l/article/details/53187795

(3)

[root@xiaofeibao ~]# vim /etc/rc.d/init.d/redis

#!/bin/sh
#
# redis init file for starting up the redis daemon
#
# chkconfig: - 20 80
# description: Starts and stops the redis daemon.

# Source function library.
. /etc/rc.d/init.d/functions

name="redis-server"
exec="/usr/sbin/$name"
pidfile="/var/run/redis/redis.pid"
REDIS_CONFIG="/etc/redis.conf"

[ -e /etc/sysconfig/redis ] && . /etc/sysconfig/redis

lockfile=/var/lock/subsys/redis

start() {
[ -f $REDIS_CONFIG ] || exit 6
[ -x $exec ] || exit 5
echo -n $"Starting $name: "
daemon --user ${REDIS_USER-redis} "$exec $REDIS_CONFIG"
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}

stop() {
echo -n $"Stopping $name: "
killproc -p $pidfile $name
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}

restart() {
stop
start
}

reload() {
false
}

rh_status() {
status -p $pidfile $name
}

"/etc/rc.d/init.d/redis" 88L, 1490C

转载于:https://www.cnblogs.com/choucat/p/7472157.html

你可能感兴趣的:(将redis添加到linux系统服务)