Summary of methods for killing processes in batches in Linux

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.