Summary of Kill and Pikill and Killall command usage for finalization processes in Linux

Source: Internet
Author: User
Tags pkill

Kill

Kill command: Sends the specified signal to the appropriate process. Do not specify the signal will send Sigterm (15) to terminate the specified process. If you still cannot terminate the program with the "-kill" parameter, it sends a signal of Sigkill (9), which will force the end of the process, using the PS command or the jobs command to view the process number. Root users will affect the user's process, and non-root users can only affect their own processes

-L < signal change Oh, without the signal number parameter, then use the "-L" parameter will list all the signal names

-a The corresponding relationship between the command name and the process number is not restricted when processing the current process

-p Specifies that the KILL command prints only the process number of the associated process without sending any signals

-s specifies to send a signal

-u Specifies user

Cases:

The code is as follows:

[Root@redhat ~]# Kill 1908 #杀死进程

[Root@redhat ~]# Kill-kill 1908 #强制杀死进程

[Root@redhat ~]# kill-9 6985 #彻底杀死进程

[Root@redhat ~]# kill-u tank #杀死指定用户的所有进程

Pkill

Pkill command: A combination of PS command and kill command to kill the specified process

-F Display Full program

-L Display Source code

-N Display new program

-O Display old programs

-V A program that does not match the condition

-X The program that matches the condition

-p< Process number > List process information for a parent process to specify a process for a user

-t< terminal > All Programs under specified terminals

-u< user > specified user's program

Cases:

The code is as follows:

[Root@redhat ~]# pkill-t tty1 #杀死终端1下的所有进程

[Root@centos ~]# pkill-kill-t PTS/2 #踢用户

[Root@redhat ~]# pkill-9 6985 #彻底杀死进程

[Root@redhat ~]# pkill-u tank #杀死指定用户的所有进程

[Root@redhat ~]# Pkill-vu Root #杀死不属于root用户的所有进程

Killall

Killall-Kill the process by name way [[]]

Killall [-EGIQVW] [-signal] name ...

Killall-l

Killall-v [[]]

DESCRIPTION (description)

Killall sends a signal to all processes that run arbitrary specified commands. If no signal name is specified, the sigterm is sent.

A signal can be specified as a name (such as a-hup) or a number (such as-1). Signal 0, which checks if a process exists, can only be specified numerically.

If the command name includes a slash (/), the process that executes the particular file is killed, regardless of the process name.

If no process can be killed for the listed command, then Killall returns a value other than 0. If at least one process is killed for each command, Killall returns 0.

The killall process will never kill itself (but can kill other killall processes). [[ ]]

Options (option)

-E

For very long names, an exact match is required. If a command name is longer than 15 characters, you may not be able to use the entire name (overflow). In this case, Killall kills all processes that match the first 15 characters of the first name. With the-e option, such a record will be ignored. If the-v option is also specified, Killall prints a message for each ignored record.

-G

Kills processes that belong to the process group. The kill signal is sent to each group only once, even if the same process group contains more than one process.

-I.

Interactive way to solicit confirmation information before killing the process.

-L

Lists all known signal names.

-Q

If no process kills, no complaints will be made.

-V

Report whether the signal was sent successfully.

-V

Displays version information.

-W

Waiting for all the killing process to die. Killall will check every second whether any of the killed processes still exist, only to be returned after the death of the dead. Note: If the signal is ignored or does not work, or the process stays in a zombie state, killall may wait forever.

Cases:

The code is as follows:

[Root@redhat ~]# killall sudo

Session end, End shell ... had been killed.

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.