The kill command is used to kill processes in linux. Next we will introduce you to an example of killing processes in batches in Linux. I hope this example can help you.
Kill a process in linux
CommandNow, we can introduce an example of killing processes in batches in Linux. I hope this example can help you.
Kill processes that contain the keyword "php-fpm" in batches.
Kill 'ps-ef | grep process name | grep-v grep | awk '{print $2 }''
For example:
Kill 'ps-ef | grep/etc/pam. d/su | grep-v grep | awk '{print $2 }''
Killing program processes containing a keyword in batches
Ps-ef | grep LOCAL = NO | grep-v grep | cut-c 9-15 | xargs kill-9
"Ps-ef" -- view all processes
"Grep php-fpm" -- list all processes that contain the keyword "php-fpm"
"Grep-v grep" -- remove the processes with the keyword "grep" from the listed processes (because the grep process we generated in the previous step also contains the keyword)
"Cut-c 9-15" -- truncates 9th to 15th characters from the input line, which is exactly the process ID
The "xargs kill-9" -- xargs command is used to take the output result (PID) of the preceding command as the parameter of the "kill-9" command and execute this command ." Kill-9 "will forcibly kill the specified process.