Friday, October 7, 2016

Running a Process in background even after SSH is closed.

Suppose you have to run a "make" for some large project that you have on a remote server. You have SSH access to it. You want to run that make (or any other) command in background even after you close the SSH connection. Here's how to do it:

1. make myApp > /path/to/output.txt 2>&1 &
   [1] 32568
2. You will see a PID on your command line like the one shown above.
3. disown 32568

You can now close the SSH connection. The output (stdout and stderr) will be in the file specified


2>&1 redirects the stderr to stdout. More about outputing streams to a file here : ( see ByteCommander's anwser).