#!/bin/bash ################################################################ # chkconfig: 2345 30 60 # description: Redis is a persistent key-value database # name: redis-server # config: /usr/local/redis/etc/redis.conf # pidfile: /usr/local/redis/var/redis.pid # USER YYYY-MM-DD - ACTION # bruce fu 20017-08-08 - Created # mail 270064522@qq.com ############################################################### source /etc/init.d/functions BIN="/usr/bin/redis-server" CONFIG="/etc/redis.conf" PIDFILE="/usr/local/redis/var/redis.pid" ### Read configuration [ -r "$SYSCONFIG" ] && source "$SYSCONFIG" RETVAL=0 prog="redis-server" desc="Redis Server" start() { if [ -e $PIDFILE ];then echo "$desc already running...." exit 1 fi echo -n $"Starting $desc: " daemon $BIN/$prog $CONFIG RETVAL=$? echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog return $RETVAL } stop() { echo -n $"Stop $desc: " killproc $prog RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog $PIDFILE return $RETVAL } restart() { stop start } case "$1" in start) start ;; stop) stop ;; restart) restart ;; condrestart) [ -e /var/lock/subsys/$prog ] && restart RETVAL=$? ;; status) status $prog RETVAL=$? ;; *) echo $"Usage: $0 {start|stop|restart|condrestart|status}" RETVAL=1 esac exit $RETVAL
转载于:https://blog.51cto.com/yibeishui/1959004