Created
July 27, 2015 09:46
-
-
Save Caixiaopig/cb2368695d09bbf57c69 to your computer and use it in GitHub Desktop.
设置redis自启动的脚本
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# redis Startup script for Redis Server | |
# | |
# chkconfig: - 80 12 | |
# description: Redis is an open source, advanced key-value store. | |
# | |
# processname: redis-server | |
# config: /etc/redis.conf | |
# pidfile: /var/run/redis.pid | |
source /etc/init.d/functions | |
BIN="/usr/local/redis/bin" | |
CONFIG="/usr/local/redis/redis.conf" | |
PIDFILE="/var/run/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment