Linux Kill multiple Processes __linux

Source: Internet
Author: User


Http://blog.chinaunix.net/uid-1757778-id-2865816.html

You often need to kill multiple processes in your work, and if these processes have common characteristics, you can kill them with a single command. For example, to clear all remote connection processes for an Oracle database:

Ps-efww|grep local=no|grep-v grep|cut-c 9-15|xargs kill-9

Pipe character "|" Used to separate two commands, the output of the command on the left side of the pipe is entered as the command to the right of the pipe character. Here are a few of the commands that are joined by a pipe character:


"Ps-efww" is a command to view all processes in red Hat 7.0. The retrieved process is then used as the input to the next command "grep local=no".


The result of the "grep local=no" is that all processes containing the keyword "local=no" are common features of the remote connection process in the Oracle database.


Grep-v grep removes the process that contains the keyword "grep" in the listed process.


"Cut-c 9-15" is the 9th character of the Intercept input line to the 15th character, which happens to be the process number PID.


The Xargs command in "Xargs kill-9" is used to take the output (PID) of the previous command as an argument to the "kill-9" command and execute the command. "Kill-9" will kill the specified process, thus successfully clearing all of Oracle's remote connection processes. For other similar tasks, just modify the keyword section of the "grep local=no".


============================ sudo pkill-u ' username '

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.