根据关键词获取进程ID然后杀掉进程
例如需要杀掉监听进程,如下:
[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
for linux and python