批量根据服务名称查询进程id然后批量杀
sudo ps -ef|grep java | awk ‘{print $2}‘|sudo xargs kill -9
sudo ps -ef|grep python |awk ‘{print $2}‘|sudo xargs kill -9
sudo ps -ef|grep process |awk ‘{print $2}‘|sudo xargs kill -9
sudo ps -ef|grep redis |awk ‘{print $2}‘|sudo xargs kill -9
sudo ps -ef|grep storage-serv |awk ‘{print $2}‘|sudo xargs kill -9
sudo ps -ef|grep mysqld |awk ‘{print $2}‘|sudo xargs kill -9
sudo ps -ef|grep kube |awk ‘{print $2}‘|sudo xargs kill -9
根据port 查询服务进程/id:
[[email protected] sbin]# lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 8246 root 6u IPv4 64233 0t0 TCP *:http (LISTEN)
nginx 8247 nobody 6u IPv4 64233 0t0 TCP *:http (LISTEN)
也可以:
[[email protected] sbin]# netstat -nlp|grep :80 标注的色的是对应服务的进程id
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 8246/nginx
原文地址:https://www.cnblogs.com/SunshineKimi/p/12146248.html