kill, killall, pkill, xkill

1. Kill Command – Kill the process by specifying its PID

All the below kill conventions will send the TERM signal to the specified process. For the signals, either the signal name or signal number can be used. You need to lookup the pid for the process and give it as an argument to kill.

$ kill -TERM pid

$ kill -SIGTERM pid

$ kill -15 pid

Example: Kill the firefox process.

$ ps -ef | grep firefox
1986 ?        Sl     7:22 /usr/lib/firefox-3.5.3/firefox

$ kill -9 1986

2. Killall Command – Kill processes by name

Instead of specifying a process by its PID, you can specify the name of the process. If more than one process runs with that name, all of them will be killed.
Example: Kill all the firefox processes

$ killall -9 firefox

3. Pkill Command – Send signal to the process based on its name

You can send signal to any process by specifying the full name or partial name. So there is no need for you to find out the PID of the process to send the signal.

Example: Send SIGTERM to all the process which has sample in its name.

$ pkill sample

Pkill Example:

Before sending signal, you can verify which are all the process is matching the criteria using “pgrep -l”, which displays the process ID and process name of the matching processes.

In this example, all the processes are designed to log the signal to signal-log, along with its PID.

$ pgrep -l sample
12406 sample-server.p
12425 sample-server.p
12430 sample-garbagec

$ pkill -USR1 sample

$ cat signal-log
Name: ./sample-server.pl Pid: 12406 Signal Received: USR1
Name: ./sample-server.pl Pid: 12425 Signal Received: USR1
Name: ./sample-garbagecollector.pl Pid: 12430 Signal Received: USR1

Note: The part of name which you specify should be in the character within the first 15 character of the process name.

4. Xkill Command – kill a client by X resource

xkill is the simplest way to kill a malfunctioning program. When you want to kill a process, initiate xkill which will offer an cross-hair cursor. Click on the window with left cursor which will kill that process.

$ xkill
Select the window whose client you wish to kill with button 1....
xkill:  killing creator of resource 0x1200003

Note: Actually, xkill instructs XServer to terminate the client.

原文地址:https://www.cnblogs.com/mydba-j/p/10289583.html

时间: 2024-11-07 09:33:04

kill, killall, pkill, xkill的相关文章

kill killall pkill 的区别

kill.pkill.killall 的作用都是终止一个进程或者正在运行的程序. kill.pkill.killall 的用法 kill 通常和grep 一起使用 常用使用方法 kill -9 + 进程id 终止进程或者进程程序 killall 直接跟程序的名字杀死所有进程 pkill 和killall的用法差不多直接跟程序,如果想杀死单个进程建议使用kill 命令 举例说明 [[email protected]localhost~]$ ps aux | grep vim pc1      25

Linux之kill,pkill,killall命令

kill,pkill,killall这些命令都是用来杀死进程的 查找进程的方法: ps -ef|grep pidof 进程名 ps命令 http://www.cnblogs.com/along1226/p/5353959.html kill [信号代码] 进程ID [[email protected]_134 ~]# kill -l 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP 6) SIGABRT 7) SIGBUS 8) SIGFPE

[Linux] killall 、kill 、pkill 命令详解

killall 命令 Linux系统中的killall命令用于杀死指定名字的进程(kill processes by name).我们可以使用kill命令杀死指定进程PID的进程,如果要找到我们需要杀死的进程,我们还需要在之前使用ps等命令再配合grep来查找进程,而killall把这两个过程合二为一,是一个很好用的命令. 1.命令格式 killall[参数][进程名] 2.命令参数 -Z 只杀死拥有scontext 的进程 -e 要求匹配进程名称 -I 忽略小写 -g 杀死进程组而不是进程 -

Linux命令(005) -- kill、pkill和killall的比较

kill命令用来“杀掉”指定进程PID的进程.终止一个前台进程可以使用Ctrl+C,终止一个后台进程就须用kill命令.kill命令是通过向进程发送指定的信号来结束相应进程的.在默认情况下,kill命令向进程发送TERM信号(15),TERM信号将终止所有不能捕获该信号的进程.如果要终止可以捕获该信号的进程就要发送kill信号(9),强行“杀掉”该进程.使用kill -9使务必小心,在数据库(Oracle.MySQL等)服务器中,尽量不要使用kill -9杀掉数据库的相关进程,这可能将给你带来灾

辛星浅析kill、pkill的区别

首先说一下kill命令,它是通过pid来杀死进程,要得到某个进程的pid,我们可以使用ps命令,默认情况下,kill命令发送给进程的终止信号是15,但是有些进程不会理这个信号,这样的话,可以用9信号来强制杀死,信号9是不会被忽略的强制性执行信号. 而killall和pkill都是使用命令名来终止进程的有效手段,它们不同于kill通过pid来杀死进程的方式,它可以理解为成批成批的杀死进程,当然这么做的危险性也相对提高了不少.当然它们也可以给进程发送相应的终止信号. 比如我们要杀死apache的相关

【转载】Linux kill, killall, kill -9

1) 查看进程的方法:  ps -ef  或者 ps aux root     15087  0.0  0.0      0     0 ?        S    23:31   0:00 [kworker/1:1]root     15219  0.0  0.0      0     0 ?        S    23:36   0:00 [kworker/1:0]root     15460  0.0  0.0      0     0 ?        S    23:41   0:0

Linux常用指令---kill | killall(终止进程)

kill Linux中的kill命令用来终止指定的进程(terminate a process)的运行,是Linux下进程管理的常用命令.通常,终止一个前台进程可以使用Ctrl+C键,但是,对于一个后台进程就须用kill命令来终止,我们就需要先使用ps/pidof/pstree/top等工具获取进程PID,然后使用kill命令来杀掉该进程.kill命令是通过向进程发送指定的信号来结束相应进程的.在默认情况下,采用编号为15的TERM信号.TERM信号将终止所有不能捕获该信号的进程.对于那些可以捕

[Linux内核]ctrl-z/fg/bg/nohup/setsid/()与&/disown/screen

转自:https://my.oschina.net/alphajay/blog/65058 My Tips: Ctrl -z    ->   suspend fg           ->   foreground bg           ->  background 1. ctrl-z.fg.bg 如果前台执行一个程序很久没执行完,那么可以用 ctrl+z挂起它,系统会做类似如下提示: 1 [1]+ Stopped sleep 100 然后可以用bg把程序调到后台执行: 1 [[em

写代码怎能不会这些Linux命令?

转自:https://zhuanlan.zhihu.com/p/28674639?hmsr=toutiao.io&utm_medium=toutiao.io&utm_source=toutiao.io 写代码怎能不会这些Linux命令? 王爵nice 3 天前 这篇文章翻译自http://www.thegeekstuff.com/2010/11/50-linux-commands/这些都是一些很常用的命令,这篇文章中每个命令都有一些简单的示例说明它的用法,对于想学习Unix/Linux的人