您的位置:首页 > 其它

根据关键词获取进程ID然后杀掉进程

2014-07-14 10:43 344 查看
例如需要杀掉监听进程,如下:

[oracle@kel ~]$ ps -ef|grep lsnr
oracle    4973     1  1 19:40 ?        00:00:00 /home/oracle/product/10.2.0/db_1/bin/tnslsnr LISTENER -inherit
oracle    4977  4868  0 19:40 pts/0    00:00:00 grep lsnr


使用下面的即可:

[oracle@kel ~]$ ps -ef|grep lsnr|grep -v grep
oracle    4973     1  0 19:40 ?        00:00:00 /home/oracle/product/10.2.0/db_1/bin/tnslsnr LISTENER -inherit
[oracle@kel ~]$ ps -ef|grep lsnr|grep -v grep|cut -c 9-15
4973
[oracle@kel ~]$ ps -ef|grep lsnr|grep -v grep|cut -c 9-15 |xargs kill -9


进程杀掉:

[oracle@kel ~]$ ps -ef|grep lsnr
oracle    5071  4868  0 19:43 pts/0    00:00:00 grep lsnr


主要命令如下:lsnr是关键词

[oracle@kel ~]$ ps -ef|grep lsnr|grep -v grep|cut -c 9-15 |xargs kill -9
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: