[Chapter 38] 38.18 nohup
Author: Jerry Peek, Tim O'Reilly & Mike Loukides
Date: 1998-08-04T21:50:05Z

#

| Chapter 38 Starting, Stopping, and Killing Processes |

## 38.18 nohup

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.)

- TOR

38.17 Automatically Kill Background Processes on Logout in csh |  | 39. Time and Performance