Skip to main content
Library homepage
Engineering LibreTexts

08-D.9.6: Process Troubleshooting - nohup and kill Commands

  • Page ID
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    The nohup Command

    The nohup command executes some other program that is specified as an argument and ignores all SIGHUP (hangup) signals. SIGHUP is a signal that is sent to a process when its controlling terminal is closed.

    For instance, if a user is connected via SSH, and the connection drops or the user logs out, the session is terminated, and all the processes executed from the terminal will terminate. This is where the nohup command can be used - it ignores all hangup signals, and the process will continue to run.


    nohup command arguments

    The kill, pkill, and killall Command

    There are three different commands in Linux which are used to terminate processes manually. kill command sends a signal to a process which terminates the process. If the user doesn’t specify any signal which is to be sent along with kill command then default TERM signal is sent that terminates the process.

    The kill and pkill commands send signals to processes directing them to terminate. Each signal has a number, name, and an associated event. Below are some of the most commonly used signals with their functionalities. A list of the various Linux signals can be found by issuing the kill command with the -l option.

    pbmac@pbmac-server $ kill -l
     1) SIGHUP       2) SIGINT         3) SIGQUIT        4) SIGILL       5) SIGTRAP
     6) SIGABRT      7) SIGBUS         8) SIGFPE         9) SIGKILL      10) SIGUSR1
    11) SIGSEGV     12) SIGUSR2       13) SIGPIPE       14) SIGALRM      15) SIGTERM
    16) SIGSTKFLT   17) SIGCHLD       18) SIGCONT       19) SIGSTOP      20) SIGTSTP
    21) SIGTTIN     22) SIGTTOU       23) SIGURG        24) SIGXCPU      25) SIGXFSZ
    26) SIGVTALRM   27) SIGPROF       28) SIGWINCH      29) SIGIO        30) SIGPWR
    31) SIGSYS      34) SIGRTMIN      35) SIGRTMIN+1    36) SIGRTMIN+2   37) SIGRTMIN+3
    38) SIGRTMIN+4  39) SIGRTMIN+5    40) SIGRTMIN+6    41) SIGRTMIN+7   42) SIGRTMIN+8
    43) SIGRTMIN+9  44) SIGRTMIN+10   45) SIGRTMIN+11   46) SIGRTMIN+12  47) SIGRTMIN+13
    48) SIGRTMIN+14 49) SIGRTMIN+15   50) SIGRTMAX-14   51) SIGRTMAX-13  52) SIGRTMAX-12
    53) SIGRTMAX-11 54) SIGRTMAX-10   55) SIGRTMAX-9    56) SIGRTMAX-8   57) SIGRTMAX-7
    58) SIGRTMAX-6  59) SIGRTMAX-5    60) SIGRTMAX-4    61) SIGRTMAX-3   62) SIGRTMAX-2
    63) SIGRTMAX-1  64) SIGRTMAX    

    Both the kill and killall commands use PIDs to determine which process is to receive the signal. The killall command terminates all programs that match a specified name.

    pbmac@pbmac-server $ ps -ef | grep sleep
    root      1337  1218  0 07:33 pts/0    00:00:00 sleep 400
    pbmac@pbmac-server $ kill -9 1337
    pbmac@pbmac-server $ ps -ef | grep sleep
    pbmac@pbmac-server $ 

    When using the pkill command the use of the command name that is to receive the signal is used.

    pbmac@pbmac-server $ pkill -9 firefox

    Kill Signals

    Signal Name Signal Value Signal Meaning
    SIGINT 2 This signal is the same as pressing CTRL-C. On some systems, "delete" + "break" sends the same signal to the process. The process is interrupted and stopped. However, the process can ignore this signal.
    SIGKILL 9 The SIGKILL signal forces the process to stop executing immediately. The program cannot ignore this signal. This process does not get to clean-up either.
    SIGTERM 15 This signal requests a process to stop running. This signal can be ignored. The process is given time to gracefully shutdown. When a program gracefully shuts down, that means it is given time to save its progress and release resources. In other words, it is not forced to stop. SIGINT is very similar to SIGTERM.
    SIGSTOP 17, 19, 23 This signal makes the operating system pause a process's execution. The process cannot ignore the signal.
    SIGSTP 18, 20, 24 This signal is like pressing CTRL-Z. This makes a request to the terminal containing the process to ask the process to stop temporarily. The process can ignore the request.

    For other signals, information can be found on the kill man page, the signal man page, and various web sites.

    08-D.9.6: Process Troubleshooting - nohup and kill Commands is shared under a CC BY-NC license and was authored, remixed, and/or curated by LibreTexts.

    • Was this article helpful?