Skip to content

Nohup command on Linux (prevents process disconnection)

Regardless of whether the programs running in the shell are first or In the background, they will be terminated when the user disconnects or closes the terminal.

This is because Jobs receive the SIGHUP (disconnect) signal, which is a warning from the terminal to its child processes that a disconnection has occurred.

To prevent this from happening, the nohup command on Linux makes the process immune to the SIGHUP signal, allowing it to Continue running even if the terminal closes or the connection drops.

In this way, the nohup utility executes the specified command without attaching it to any terminal, immune to connection drops and disconnections.

In this example, nohup will execute the command find/-name uira* and send the output to files_found, and it will still run in the background:

$ nohup find/-name uira* > files_found &

Nohup executes the specified command but doesn’t allow it to receive any data input through the terminal.

All output (STDOUT), including error messages (STDERR), will be written to the nohup.out file in the working directory or local directory.

You can use nohup in the foreground or in the background. The most common is to run it in the background by placing the ”&” at the end of the command line.

Learn much more about Linux in our online course. You can register here. If you already have an account, or want to create one, just log in or create your user here.

Did you like it?

Share