How can I stop redis-server?

前端 未结 26 1577
清歌不尽
清歌不尽 2020-12-07 06:51

I apparently have a redis-server instance running because when I try to start a new server by entering redis-server, I\'m greeted with the followin

相关标签:
26条回答
  • 2020-12-07 07:12

    Option 1: go to redis installation directory and navigate to src , in my case :

    /opt/redis3/src/redis-cli -p 6379 shutdown
    

    where 6379 is the default port.

    Option 2: find redis process and kill

    ps aux | grep redis-server
    
    t6b3fg   22292  0.0  0.0 106360  1588 pts/0    S+   01:19   0:00 /bin/sh /sbin/service redis start
    t6b3fg   22299  0.0  0.0  11340  1200 pts/0    S+   01:19   0:00 /bin/sh /etc/init.d/redis start
    

    And Then initiate kill:

    kill -9 22292
    
    kill -9 22299
    

    I'm using Centos 6.7 , x86_64

    hope it helps

    0 讨论(0)
  • 2020-12-07 07:17

    Another way could be :

    brew services stop redis
    
    0 讨论(0)
  • 2020-12-07 07:18

    Try killall redis-server. You may also use ps aux to find the name and pid of your server, and then kill it with kill -9 here_pid_number.

    0 讨论(0)
  • 2020-12-07 07:19

    If you know on what port it would be running(by default it would be 6379), you can use below command to get the pid of the process using that port and then can execute kill command for the same pid.

    sudo lsof -i : <port> | awk '{print $2}'
    

    the above command will give you pid.

    kill <pid>;

    This would shutdown your server.

    0 讨论(0)
  • 2020-12-07 07:20

    On MacOSX,

    This is what worked for me

    /etc/init.d/redis restart
    
    /etc/init.d/redis stop
    
    /etc/init.d/redis start
    
    0 讨论(0)
  • 2020-12-07 07:20

    You can try this code:

    sudo kill -9 $(ps aux | grep 'redis' | awk '{print $2}')
    
    0 讨论(0)
提交回复
热议问题