How To Use Linux Nohup Command To Execute Commands After Exit Shell or Terminal? – POFTUT

How To Use Linux Nohup Command To Execute Commands After Exit Shell or Terminal?

nohup is a command used to ignore HUP signal. HUP signal is used to kill a shell command if the parent shell exits. Think that we logged in with ssh and run a command. But the command execution takes a lot of time. We need to log out. In normal sense if we log out our command execution will end. In this case we will provide nohup command to prevent command termination even the ssh logout. Nohup is natively provided by Linux distributions, Unix and BSD.


As we can see nohup command have two type of syntax. In the first one we will provide the command and arguments. In the second one we can use just two options named --help and --version .


Nohup is very easy command to use in previous syntax section as wee see. We will just provide command after nohup command we want to execute.

Nohup Usage

We have appended ampersand to make run our process in the background and not bind to the current terminal.

Execute with Redirection

We can redirect nohup  command output to the different commands or files. As bash provides > for redirection we will use it to write nohup  command a  file named myoutput.txt in this example.

Use with Find Command

In this example we will use find command which will run even we will close current shell.

LEARN MORE  Awk Print Tutorial With Examples

We also use & which sends the process background and gives current shell to us. This will gives us the message ignoring input and redirecting stderr to stdout like below.

Find Nohup Example

Find Nohup Example

Situations Of Nohup Usage

We can use nohup command in the following cases.

  • Synchronization
  • Tomcat Server Restart
  • Memory Check

Leave a Reply

Your email address will not be published. Required fields are marked *

Enjoy this blog? Please spread the word :)