Starting a process remotely with nohup command

Published on Oct 15 2016

Every process which starts from a terminal is tied to shell as a child process from which it was executed. When the parent program is terminated the child process will be terminated, this is not particularity desired behavior when a user needs to run a process remotely and keep the process running after logout, for this reason a nohup command exists.

Syntax for nohup is as follows:

$ nohup my-command > my-command.out &

Example: Run a yes command with nohup and redirect the output to /dev/null. Prepend & to run the command in the background:

$ nohup yes > /dev/null &
[1] 3594

An output file will be created and this will capture any STDOUT coming from my-command.out which returns a shell as it runs my-command in the background.

Close or log out from the terminal, open another session and run the following command:

ps aux | grep yes
lilo      3594 98.3  0.0   3016   504 ?        R    11:06   1:23 yes

Note that process PID 3594 is still running.

To kill a process by PID:

kill 3594


starting a process remotely with nohup command

Updated by db Oct 15 2016 , filed under Linux