The Linux kernel allows many signals to be sent to processes. Use man 7 signals for a complete overview of all the available signals. Three of these signals work for all processes:
■ The signal SIGTERM (15) is used to ask a process to stop.
■ The signal SIGKILL (9) is used to force a process to stop.
■ The SIGHUP (1) signal is used to hang up a process. The effect is that the process will reread its configuration files, which makes this a useful signal to use after making modifications to a process configuration file.

To send a signal to a process, the kill command is used. The most common use is the need to stop a process, which you can do by using the kill command followed by the PID of the process. This sends the SIGTERM signal to the process, which normally causes the process to cease its activity. Sometimes the kill command does not work because the process you want to kill is busy. In that case, you can use kill -9 to send the SIGKILL signal to the process. Because the SIGKILL signal cannot be ignored, it forces the process to stop, but you also risk losing data while using this command. In general, it is a bad idea to use kill -9 :
■ You risk losing data.
■ Your system may become unstable if other processes depend on the process you have just killed.
TIP Use kill -l to show a list of available signals that can be used with kill .

  1. [root@rhel7 ~]# kill -l
  2. ) SIGHUP ) SIGINT ) SIGQUIT ) SIGILL ) SIGTRAP
  3. ) SIGABRT ) SIGBUS ) SIGFPE ) SIGKILL ) SIGUSR1
  4. ) SIGSEGV ) SIGUSR2 ) SIGPIPE ) SIGALRM ) SIGTERM
  5. ) SIGSTKFLT ) SIGCHLD ) SIGCONT ) SIGSTOP ) SIGTSTP
  6. ) SIGTTIN ) SIGTTOU ) SIGURG ) SIGXCPU ) SIGXFSZ
  7. ) SIGVTALRM ) SIGPROF ) SIGWINCH ) SIGIO ) SIGPWR
  8. ) SIGSYS ) SIGRTMIN ) SIGRTMIN+ ) SIGRTMIN+ ) SIGRTMIN+
  9. ) SIGRTMIN+ ) SIGRTMIN+ ) SIGRTMIN+ ) SIGRTMIN+ ) SIGRTMIN+
  10. ) SIGRTMIN+ ) SIGRTMIN+ ) SIGRTMIN+ ) SIGRTMIN+ ) SIGRTMIN+
  11. ) SIGRTMIN+ ) SIGRTMIN+ ) SIGRTMAX- ) SIGRTMAX- ) SIGRTMAX-
  12. ) SIGRTMAX- ) SIGRTMAX- ) SIGRTMAX- ) SIGRTMAX- ) SIGRTMAX-
  13. ) SIGRTMAX- ) SIGRTMAX- ) SIGRTMAX- ) SIGRTMAX- ) SIGRTMAX-
  14. ) SIGRTMAX- ) SIGRTMAX
  15. [root@rhel7 ~]#

There are some commands that are related to kill:  killall  and  pkill . The  pkill  command is a bit easier to use because it takes the name rather than the PID of the process as an argument. You can use the  killall  command if multiple processes using the same name need to be killed simultaneously.   Using  killall  was particularly common when Linux environments were multiprocessing instead of multithreading. In a multiprocessing environment where a server starts several commands, all with the same name, it is not easy to stop these commands one by one based on their individual PID. Using  killall  enables you to terminate all these processes simultaneously.

Sending Signals to Processes with kill, killall, and pkill的更多相关文章

  1. Linux:INIT runlevel service netstat ps top pgrep kill killall jobs pkill crontab

    INIT进程 Linux内核加载执行/sbin/init程序 -Linux的第一个进程,进程ID为1 -主配置文件:/etc/ininttab init 0 关机 init 1 单用户模式 init ...

  2. 【进程/作业管理】篇章一:Linux进程及其管理(进程管理类工具)----pstree、ps、top、htop、kill、(killall、pkill、pgrep、pidof)

    主要讲解进程管理类命令及工具的使用:pstree.ps.top.htop.kill.(killall.pkill.pgrep.pidof) pstree 以树状图的方式展现进程之间的派生关系,显示效果 ...

  3. kill、killall、pkill杀手三人组

    1.1 kill.killall.pkill杀手三人组 1.利用kill 进程号 方式杀掉rsync进程 [root@backup ~]# ps -ef |grep rsync root 3500 1 ...

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

    1) 查看进程的方法:  ps -ef  或者 ps aux root     15087  0.0  0.0      0     0 ?        S    23:31   0:00 [kwo ...

  5. Linux终止进程的工具kill/killall/pkill/xkill/skill用法区别(转)

    一. 终止进程的工具kill .killall.pkill.xkill 终止一个进程或终止一个正在运行的程序,一般是通过kill .killall.pkill.xkill等进行.比如一个程序已经死掉, ...

  6. 【Linux命令】常用系统工作命令11个(echo、date、reboot、poweroff、wget、ps、top、pidof、kill、killall、pkill)

    目录 echo命令 date命令 reboot命令 poweroff命令 wget命令 ps命令 top命令 pidof命令 kill命令 killall命令 pkill命令 一.echo命令 ech ...

  7. 【Linux常用命令】Linux kill, killall, kill -9,

    参考链接 https://blog.csdn.net/zong596568821xp/article/details/77899454 kill + PID kill -9 + PID  加上-9 是 ...

  8. centos下kill、killall、pkill命令区别

    kill是用来终止进程的 首先可以通过ps aux查看系统有哪些进程正在运行. 1.用kill来杀死某一个进程 #kill,加选项-9,加PID,表示杀死进程编号为PID的这个进程# -1 重启#ki ...

  9. kill, killall, pkill, xkill

    1. Kill Command – Kill the process by specifying its PID All the below kill conventions will send th ...

随机推荐

  1. hdu 4631(最近点对,容器)

    点击打开链接 题意: 给你一个平面,每次加入一个点,当点数>=2时,求最近点对距离的平方,最后输出所有的平方和. 给你a,b,c x[0]=0;x[i]=(x[i-1]*a+b)%c 如果按照平 ...

  2. Linux 4.1内核编译报告

    编译环境 Arch Linux on VirtualBox 下载内核 https://www.kernel.org/ 下载的内核压缩包,此时的最新内核版本为4.1: 解压包 # tar -xvJf l ...

  3. 页面d初始化加载

    1.$(document).ready(function () { alert("Hello Word!"); }); 或简写为 2.$(function(){ alert(&qu ...

  4. C# .net 如何根据访问者IP获取所在地区

    第一步:在根目录添加新项(类),新建一个类文件,把以下文件粘贴到该类文件下:   using System; using System.Collections.Generic; using Syste ...

  5. Python新手学习基础之数据结构-序列2

    长度.最大值和最小值 序列类型的数据结构,常常会用到长度检查.最大最小值检查的函数. 他们的作用: len(序列):返回列表的长度(元素个数): max(序列) :返回列表中元素最大值: min(序列 ...

  6. iOS6 自动布局 入门–Auto Layout(转)

    iOS6 自动布局 入门–Auto Layout(转) 标签: 杂谈   目前为止,即使你的界面设计是在合理的复杂度内,你也必须要为之写许多代码来适应变化的布局.现在我相信你会很高兴听到这种情况将不会 ...

  7. 【Hybrid App】一个产品经理眼中的PhoneGap Vs. AppCan

    首先在写这篇文章前,必须先申明一下,本人是技术出身,对HTML技术及手机客户端都有过编程经验,只是出于工作岗位的变动,便没有再具体代码工作,以下文章涉及的中间件的基本代码实现及前期的API使用,都是自 ...

  8. Win7 下用 VS2015 编译最新 openssl(1.0.2j)包含32、64位debug和release版本的dll、lib(8个版本)

    Win7 64位系统下通过VS2015编译好的最新的OpenSSL(1.0.2j)所有八个版本的链接库, 包含以下八个版本: 1.32位.debug版LIB: 2.32位.release版LIB: 3 ...

  9. 关于索引degree设置的问题

    --并行查询 可以使用并行查询的情况 1. Full table scans, full partition scans, and fast full index scans 2. Index ful ...

  10. Delphi 多线程 “尚未调用CoInitialize错误”的解决方法

    在Delphi  多线程中出现“尚未调用CoInitialize错误”的解决方法 解决方法如下: function  TMyThread.ExecTimer: Boolean;begin  Resul ...