home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 38.17 Automatically Kill Background Processes on Logout in csh Chapter 38
Starting, Stopping, and Killing Processes
Next: 39. Time and Performance
 

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 h angup ") 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


Previous: 38.17 Automatically Kill Background Processes on Logout in csh UNIX Power Tools Next: 39. Time and Performance
38.17 Automatically Kill Background Processes on Logout in csh Book Index 39. Time and Performance

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System