通过命令名称查询进程id

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

 

你可能感兴趣的:(查询进程id)