When UNIX first started, even local terminals very often communicated with the system via short-haul modems. (After all, UNIX was invented by the phone company.) When someone logged out, the modem hung up the phone - and conversely, if the modem hung up, a "hangup" signal was sent to the login shell, whereupon it terminated, bringing down all its child processes (38.3) with it.
In the C shell, processes that you run in the background are immune to hangups, but in the Bourne shell, a process that you started in the background might be abruptly terminated.
nohup | The nohup command ("no hangup") allows you to circumvent this. (The GNU version is on the CD-ROM.) Simply type: |
---|
$nohup
command
&
Any output from command
that would normally go to the
terminal (i.e., has not been redirected) goes to a file named nohup.out
in the current directory.
Of course, if you want to run jobs at off hours, you might do even better using at, cron, or batch (40.1).
nohup is sometimes handy in shell scripts to make them ignore the HUP and TERM signals (38.8), though trap (44.12) is more versatile. (In System V, nohup causes a command to ignore HUP and QUIT, but not TERM.)
-