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