redis restart code example
Example 1: redis server stop
$ redis-cli shutdown
Example 2: start redis server
$ redis-server
Example 3: brew stop redis
brew services start|run redis
brew services stop redis
Example 4: script for restart redis service automatically
#!/bin/bash
a=$(redis-cli -p 6379 PING)
if [ "$a" = "PONG" ]
then
echo 'Already running'
else
b=$(/etc/init.d/redis_6379 start)
echo $b
fi