Skip to content

Instantly share code, notes, and snippets.

@midwire
Created July 10, 2014 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save midwire/61348395c8b7ef2550fe to your computer and use it in GitHub Desktop.
Save midwire/61348395c8b7ef2550fe to your computer and use it in GitHub Desktop.
Redis server control script.
#!/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