linux get PID according to process name

Kill often need multiple processes that include common keywords, you can use a command Kill rid of them.

ps aux | grep "common" |grep -v grep| cut -c 9-15 | xargs kill -9

Pipe character "|" designed to separate the two commands, command pipe character to the left of the output will be used as input pipe symbol to the right of command. The following talk by pipe coupling together several commands:

"Ps aux" command to view all the processes. Then retrieved process will grep "common" input as the next command.

"Grep" common "you select all contain the keyword 'process common" of.

"Cut -c 9-15" intercept enter on line 9 of the characters to 15 characters, and this is precisely the process ID PID.

grep -v grep 除去 "grip"

wc -l statistical line number

"xargs kill -9" xargs command is used in the preceding command output (PID) as a "kill -9" command parameter, and executes the command. "kill -9" will be forced to kill the designation process
----------------
Disclaimer: This article is CSDN blogger "mengfanteng 'original article, follow the CC 4.0 BY-SA copyright agreement , reproduced, please attach the original source link and this statement.
Original link: https: //blog.csdn.net/mtt_sky/article/details/52462145

Guess you like

Origin www.cnblogs.com/linbky/p/11599150.html