I want to stop the redis server and it just keeps going and going. I am using redis-2.6.7
Check that it is running:
redis-server
It say
Best way check pid of redis opened port :
lsof -i:<redis-port>
for default redis port
lsof -i:6379
kill -9 <pid>
redis-cli -a password shutdown
or
ps aux|grep redis
kill -9 <redis pid>
The above solutions doesn't work. The redis server will restart with a new pid. But the below command works.
/etc/init.d/redis-server stop
My server is Ubuntu 18.04.2 and Redis version is v4.0.9
On windows this worked:
Open terminal(PowerShell/CMD), type:
wsl --shutdown
It will end your virtual machine.
start redis: $REDIS_HOME/src/redis-server
stop redis: $REDIS_HOME/src/redis-cli shutdown
$REDIS_HOME
where you have installed/extracted redis.
I finally got it down.
Get the PID of the process (this worked in Webfaction):
ps -u my_account -o pid,rss,command | grep redis
Then
> kill -9 the_pid
I was able to REPRODUCE this issue:
Start redis-server
Then break it using Pause/Break key
Now it hangs and it won't shutdown normally. Also the Python program trying to set/get a key hangs. To avoid this: Just close the window after starting redis-server. It's now running normally.
This is possibly an really important note for some people reading this. If your redis doesn't seem to be responding to a shutdown. CHECK THE LOGS.
They may say something like this:
Apr 24 00:48:54 redis[828]: Received SIGTERM, scheduling shutdown...
Apr 24 00:48:54 redis[828]: User requested shutdown, saving DB...
Apr 24 00:55:37 redis[828]: DB saved on disk
Maybe your DB is multiple GB, or tens of GBs in which case it will take time to shutdown. If instead you want to clean out all keys, there is a better way to do that than shutdown. FLUSHALL