pavement

Nohup

From FreeBSDwiki
Revision as of 16:21, 8 September 2006 by Jimbo (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

nohup is a godsend for those of us who spend lots of time shelling into remote machines. You can invoke any other command with nohup, like the following:

ph34r# nohup find / -name "*a*" > /home/jimbo/dumbfindcommand.out

And what happens is, your command gets executed but told to ignore all SIGHUP signals. The net impact is, you can now close your shell session, and still have your command continue to run - whereas normally, as soon as your shell died - either due to you closing it or to the vagaries of the internet closing it for you - all processes you had running would immediately die as well.

The example given above - give me a listing of every single file on my entire server which contains the letter "a" in its name - would obviously take an absurdly long time to run. If you had to accomplish a task like this on a machine hundreds of miles away, it would be nearly impossible without finding some way of detaching it from your shell session. You could also use the at scheduler, but that can be a real pain because it only fires off every 5 minutes (by default), and you hate to just set something up and walk away without checking to see that it fired up and began doing what it was supposed to. With nohup, you can just fire it up immediately, use a ps or other command to monitor that it is running and appears to be doing what it ought to be doing, and then quit worrying about it 'til it's done.

Personal tools