实用的kill脚本(ps -ef | grep keepalived | grep -v grep | awk ‘{print $2}‘ | xargs kill -9)

1.查看进程:

ps -ef | grep keepalived

2.grep -v grep 命令可以忽略grep这个进程

ps -ef | grep keepalived | grep -v grep

实用的kill脚本(ps -ef | grep keepalived | grep -v grep | awk ‘{print $2}‘ | xargs kill -9)_第1张图片

实用的kill脚本(ps -ef | grep keepalived | grep -v grep | awk ‘{print $2}‘ | xargs kill -9)_第2张图片

3.awk ‘{print $2}’ 命令截取进程号

 ps -ef | grep keepalived | grep -v grep | awk '{print $2}'

实用的kill脚本(ps -ef | grep keepalived | grep -v grep | awk ‘{print $2}‘ | xargs kill -9)_第3张图片
4.xargs 命令把前面的输出作为后面命令kill -9 的输入,也就是传左边命令截取的进程号给命令kill -9

ps -ef | grep keepalived | grep -v grep | awk '{print $2}' | xargs kill -9

请添加图片描述

5.查看是否杀死进程

ps -ef | grep keepalived

请添加图片描述

你可能感兴趣的:(linux,运维,服务器)