1.已知端口號
根據(jù)端口查看這個進(jìn)程的pid
[root@study redis-4.0.11]# netstat -lnp|grep 6379
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 11176/src/redis-ser
tcp6 0 0 :::6379 :::* LISTEN 11176/src/redis-ser
可能會出現(xiàn)如下提示:
(No info could be read for "-p": geteuid()=1000 but you should be root.)
解決方法:切換到root用戶
查看進(jìn)程的詳細(xì)信息
[root@study redis-4.0.11]# ps 11176
PID TTY STAT TIME COMMAND
11176 pts/0 Sl 0:00 src/redis-server *:6379
殺掉進(jìn)程
[root@study redis-4.0.11]# kill 11176
2. 已知服務(wù)名稱
根據(jù)服務(wù)名查看進(jìn)程的詳細(xì)信息
[root@study redis-4.0.11]# ps -ef|grep redis
root 11176 11150 0 05:12 pts/0 00:00:00 src/redis-server *:6379
root 11184 11150 0 05:14 pts/0 00:00:00 grep --color=auto redis
通過pid看端口
[root@study redis-4.0.11]# netstat -antup|grep 11176
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 11176/src/redis-ser
tcp6 0 0 :::6379 :::* LISTEN 11176/src/redis-ser