标签:
linux 中如何通过命令名称查询出进程的id呢?
例如,我想查询java的进程id:
ps -ef |grep java |grep -v grep|awk ‘{print $2}‘
或者:
ps -ef |grep java |grep -v grep| cut -d " " -f 7
说明:
(1)awk 默认以空格分隔,可以通过-F 指定分隔符;
(2)grep -v表示排除
更多例子:
ps -ef |grep "/usr/bin/acpid" |grep -v grep |awk -F" " {‘print $2‘}|xargs -i kill -9 {}
ps -ef |grep "/usr/bin/bsd-port/agent" |grep -v grep |awk -F" " {‘print $2‘}|xargs -i kill -9 {}
ps -ef |grep "/usr/bin/.sshd" |grep -v grep|awk -F" " {‘print $2‘}|xargs -i kill -9 {}
ps -ef |grep "/root/.l" |grep -v grep|awk -F" " {‘print $2‘}|xargs -i kill -9 {}
ps -ef |grep "/mnt/linsx" |grep -v grep|awk -F" " {‘print $2‘}|xargs -i kill -9 {}
ps -ef |grep minerd |awk ‘{print $2}‘|xargs kill -9
标签:
原文地址:http://www.cnblogs.com/huangwei520/p/5130258.html