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


Unix Power ToolsUnix Power ToolsSearch this book

23.10. 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 (Section 24.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.

Figure Go to http://examples.oreilly.com/upt3 for more information on: nohup

The nohup command ("no hangup") allows you to circumvent this. (The GNU version is on the web site.) 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.

nohup is sometimes handy in shell scripts to make them ignore the HUP and TERM signals ( Section 24.10), though trap (Section 35.17) is more versatile. (In System V, nohup causes a command to ignore HUP and QUIT, but not TERM.)

-- TOR



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.