Original URL: http://www.cnblogs.com/peida/archive/2012/12/21/2827366.html
The Killall command in a Linux system is used to kill a process with the specified name (kill processes by name). We can use the KILL command to kill the process of the specified process PID, if we want to find the process we need to kill, we also need to use the PS and other commands to match grep to find the process, and killall the two processes into one, is a very useful command.
1. Command format:
killall[parameter [process name]
2. Command function:
Used to end all processes with the same name
3. Command parameters:
-Z kills only the process that owns Scontext
-e requires matching process name
-I ignore lowercase
-G kills Process group instead of process
-I interactive mode, ask the user before killing process
-l list all known signal names
-Q does not output a warning message
-S sends the specified signal
-V reports whether the signal was sent successfully
-W wait for process to die
--HELP Display Help information
--version Display version display
4. Usage examples:
Example 1: Kill all processes with the same name
Command:
Killall VI
Output:
[Email protected] ~]# Ps-ef|grep VI
Root 17581 17398 0 17:51 pts/0 00:00:00 vi test.txt
Root 17611 17582 0 17:51 pts/1 00:00:00 grep VI
[Email protected] ~]# Ps-ef|grep VI
Root 17581 17398 0 17:51 pts/0 00:00:00 vi test.txt
Root 17640 17612 0 17:51 pts/2 00:00:00 VI test.log
Root 17642 17582 0 17:51 pts/1 00:00:00 grep VI
[Email protected] ~]# Killall VI
[Email protected] ~]# Ps-ef|grep VI
Root 17645 17582 0 17:52 pts/1 00:00:00 grep VI
Description
Example 2: Sending a specified signal to a process
Command:
Background Running program: VI &
Kill VI Process: Killall-term VI or Killall-kill VI
Output:
[Email protected] ~]# VI &
[1] 17646[[email protected] ~]# killall-term VI
[1]+ Stopped VI
[Email protected] ~]# VI &
[2] 17648[[email protected] ~]# Ps-ef|grep VI
Root 17646 17582 0 17:54 pts/1 00:00:00 VI
Root 17648 17582 0 17:54 pts/1 00:00:00 VI
Root 17650 17582 0 17:55 pts/1 00:00:00 grep VI
[2]+ Stopped VI
[Email protected] ~]# Killall-term VI
[Email protected] ~]# Ps-ef|grep VI
Root 17646 17582 0 17:54 pts/1 00:00:00 VI
Root 17648 17582 0 17:54 pts/1 00:00:00 VI
Root 17653 17582 0 17:55 pts/1 00:00:00 grep VI
[Email protected] ~]# Killall-kill VI
[1]-has killed VI
[2]+ has killed VI
[Email protected] ~]# Ps-ef|grep VI
Root 17656 17582 0 17:56 pts/1 00:00:00 grep VI
[Email protected] ~]#
Description
Example 3: Kill all the shells that have been logged in
Command:
Killall-9 Bash
Output:
[Email protected] ~]# W
18:01:03 up-18:53, 3 users, Load average:0.00, 0.00, 0.00USER TTY from [email protected] IDLE Jcpu PCPU What
Root pts/0 10.2.0.68 14:58 9:52 0.10s 0.10s-bash
Root pts/1 10.2.0.68 17:51 0.00s 0.02s 0.00s W
Root PTS/2 10.2.0.68 17:51 9:24 0.01s 0.01s-bash
[Email protected] ~]# killall-9 bash
[Email protected] ~]# W
18:01:48 up-18:54, 1 user, load average:0.07, 0.02, 0.00USER TTY from [email protected] IDLE Jcpu PCPU What
Root pts/0 10.2.0.68 18:01 0.00s 0.01s 0.00s W
[Email protected] ~]#
Description
Run command: After killall-9 bash, all bash will be stuck, so all connections are currently missing. Need to reconnect and log in.
"Go" one Linux command per day: Killall command