shell 杀掉指定进程的服务

check_results=`ps -ef|grep bp_driver.launch|awk '{print $2}'|sed -n 1p`
echo `kill -2 $check_results`

运行上面的命令后,杀掉下方19158进程

higgs    19158 17223  1 04:00 pts/17   00:00:01 /usr/bin/python /opt/ros/indigo/bin/roslaunch blackpearl bp_driver.launch
higgs    20439 19866  0 04:02 pts/18   00:00:00 grep --color=auto bp_driver

  

原文地址:https://www.cnblogs.com/sea-stream/p/9669519.html