Nohup is a command in Linux systems that allows processes to continue running even after exiting the shell or terminal. When a command is executed in Linux, a process is started, which is automatically terminated upon exiting the terminal. However, if the process is started with nohup, it will ignore the hangup signal (SIGHUP) and continue running even after logging out from the shell/terminal.
Here are some key features of nohup:
-
Background execution: Running commands in the background can be very helpful to the user, especially when executing programs over SSH and the connection drops. In such cases, nohup can be used to run the command in the background and prevent the session from being terminated.
-
Signal blocking: Nohup catches the hangup signal and blocks it, allowing the process to continue running even after logging out from the shell/terminal.
-
Output redirection: Once a job is started or executed using the nohup command, stdin will not be available to the user, and nohup.out file is used as the default file for stdout and stderr. If the output of the nohup command is redirected to some other file, nohup.out file is not generated.
To use nohup, the syntax is `nohup command .
It is important to note that nohup does not put the job automatically in the background, and we need to tell that explicitly using &
. Additionally, there are cases where nohup does not work, such as when the process you start reconnects the NOHUP signal.