Sunday, August 18, 2013

nohup - run a command immune to hangups (terminal close)

Say you're on business trip, ssh to a remote server, run a command to compile some huge source code which take hours, or process date which takes days, but then you need to close your laptop and run the next site.  Closing the terminal will also kill all the process you started.  What should you do?

nohup is is there to help you.:
NAME
       nohup - run a command immune to hangups, with output to a non-tty

SYNOPSIS
       nohup COMMAND [ARG]...
       nohup OPTION

DESCRIPTION
       Run COMMAND, ignoring hangup signals.

Take an example of compiling a fresh configured buildroot, depends on the packages selected it takes hours/days to download the sources and compile:
EXAMPLE
       $ nohup make buildroot &

Then the buildroot compilation will continue after you close your terminal/laptop.

No comments: