Created
July 10, 2014 13:59
-
-
Save midwire/61348395c8b7ef2550fe to your computer and use it in GitHub Desktop.
Redis server control script.
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
#!/usr/bin/env bash | |
cmd=$1 | |
function start_redis() { | |
nohup redis-server /usr/local/etc/redis.conf > /dev/null 2>&1 & | |
} | |
function stop_redis() { | |
redis-cli shutdown | |
} | |
case $cmd in | |
start ) | |
start_redis | |
;; | |
stop ) | |
stop_redis | |
;; | |
restart ) | |
stop_redis | |
start_redis | |
;; | |
status ) | |
x=`redis-cli time` | |
if [ $? == 0 ]; then | |
echo "Redis is running." | |
else | |
echo "Redis is NOT running." | |
fi | |
;; | |
* ) | |
echo "Usage: $0 [status, start, stop, restart]" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment