王昱棋

导航

如何在脚本中杀掉进程

大佬那里找来的命令:https://www.cnblogs.com/linjiqin/p/7877721.html
作为备份,方便查找,就直接抄过来了,不过杀程序时要小心,不要误伤别的进程。

查找tomcat进程
ps -ef | grep tomcat | grep -v grep | awk '{print $2}'
查找tomcat进程并杀死
ps -ef | grep tomcat | grep -v grep | awk '{print $2}' | xargs kill -9
或者
kill -9  `ps -ef | grep tomcat| grep -v grep |awk '{print $2}'`

posted on 2020-09-16 18:25  王昱棋  阅读(388)  评论(0编辑  收藏  举报