Kill, killall, and pkill tools used to terminate processes-Linux technology and application information. For details, refer to the following section. Terminate a process, generally through kill, killall, pkill, xkill, and so on. For example, if a program is dead but cannot exit, you should consider using these tools.
In addition, in server management, you can use these tools to stop the parent process that does not involve database server programs. Why cannot the parent process of the database server be killed using these tools? The reason is simple. When these tools force terminate the database server, more file fragments will be generated for the database. When the fragmentation reaches a certain level, the database may crash. For example, it is best to close the mysql server according to its normal program, instead of using pkill mysqld or killall mysqld as dangerous actions. Of course, we should use kill to kill database sub-processes that occupy too much resources.
Kill
Kill is generally used together with ps or pgrep commands.
Kill [signal code] process ID
Note: The signal code can be omitted (the signal code is 15 and ends normally). Our commonly used signal code is 9, which indicates force termination.
Example:
[Root @ localhost ~] # Pgrep-l gaim
5031 gaim
[Root @ localhost ~] # Kill-9 5031
Killall
Killall directly kills all processes by program name
Usage: name of the program that is running killall
Killall can also be used with ps or pgrep for ease of use.
Use ps or pgrep to check which programs are running
Example:
[Root @ localhost test] # pgrep-l gaim
2979 gaim
[Root @ localhost test] # killall gaim
Pkill
The pkill method is similar to the killall method. It also directly kills the running program. If you want to kill a single process, use kill to kill it.
Application Method: pkill name of the running program
Example:
[Root @ localhost test] # pgrep-l gaim
2979 gaim
[Root @ localhost test] # pkill gaim
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