Killall five options you might not know

  Linux command line provides many commands to kill the process. For example, you can to "kill" a PID transfer command to kill the process; "pkill" command to use a regular expression as input, and therefore the pattern matching process have been killed.

  But there is a command called "killall", by default, it exactly matches the parameter name, then kill the matching process. In this article, we will discuss about the practical application of this command.

  Linux's command killall

  killall a specific command can be used to transmit a signal process. By default, this signal is SIGTERM, but may also be used to specify other parameters by the killall command signals.

  Now let's look at the actual usage of this command by some practical examples.

  Example 1. Basic

  In this example, we will use killall to kill specific process. If, with the same process begins with two characters:

  

 

  How to Kill "test_again" process?

  

 

  As you can see, killall command terminated "test_again" process. You can confirm this fact by the ps command:

  

 

  You can observe "test_again" is not shown because it has been killed.

  2. Use the -I option to ignore case

  By default, killall command is case sensitive. E.g:

  

 

  As you can see, killall command can not be found is called "TEST" in the process, but "test" process is indeed in the running.

  To make killall command to ignore case, use the -I option (uppercase i). E.g:

  

 

  You can observe, now you have successfully ended the "test" process.

  3. Use the -i option to terminate an interactive process

  killall command can be used to terminate multiple processes.

  

 

  However, if you want to terminate the process killall interactively, you can use the -i option.

  Here is an example:

  

 

  As you can see, this way, at the time of termination of multiple processes at the same time, the user can control whether to terminate a particular process.

  4. Use the -q option to turn off command echoing

  Sometimes, when killall not find the specified process, it will output an error message like this.

  

 

  But when you want to execute killall quietly, you can use the -q option:

  

 

  As you can see, -q option is used after the killall command output are suppressed.

  5. signal using the -l option to list all supported (signal)

  As previously described, like, killall sends a signal to the process.

  You can send a special signal to a process with the -s option (followed by a signal name).

  I want to know all the signals can be sent, you can use the -l option (lowercase L) to obtain:

  

 

  killall supports all signals above.

  Looking at the names of these signals, may your heart will whisper: These signals are doing?

  Translator's Note: Use the following command to get all signal instructions:

  

 

  I need one thing and discussion

  man killall command, said: If the length of the name of the process that is less than or equal to 15, it will default to match the full name.

  For example, suppose there are two names long process:

  

 

  The first process name has 15 characters. Now, let's try to use killall kill the process:

  

 

  It only kills the specified process, the other is not killed.

  

 

  I'm not sure, I was trying to be in the wrong place, or is this a bug killall's. If you write your ideas in the comments, I would be very grateful.

  By the way, this is the version information on my machine killall command:

  

 

  Linux from China

  

 

Guess you like

Origin www.cnblogs.com/qfjavabd/p/10962631.html