linux 中如何通过命令名称查询出进程的id呢?\
例如,我想查询Java的进程id:
ps -ef |grep java |grep -v grep|awk '{print $2}'
说明:
(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