Life of a geek is not without its temptations, they come sometimes in the guise of friends asking me to join for a steaming hot cup of coffee or the company of a sweet young thing :o)
Mostly I give in to temptations and allow myself to be drawn away from my computer terminal. Being a little paranoid about security I don't leave my console unattended instead I prefer to log off completely. But that's not always possible since I have quite a few jobs running in background, now what is fastest and the best way to get rid of them so that I can log off and leave them running after I am gone? disown is the answer. This bash specific command allows us to unbind various jobs from the current login session. I use 'disown <jobid>' to get rid of the job(s) running on my console login session. Volia now I can logoff and run.
But wait why not use some computing time while I am gone, perhaps I can compile a new kernel or download a package with wget. Using the nohup command is apt here since I am planning to logoff leaving the computer to do the tasks. Just prefix nohup before any command and run it in the background by placing "&" at the end of the command, that's it.
How does disown and nohup commands work? What they do is that they connect all your process to the parent process of the computer which happens to init (the granddaddy of all process running on the computer). Viewing all the process on the computer help us understand it better, Look a the the output of the pstree command below. The init is first (root of the inverted tree) process which radiates all the other process in the computer. Here you can see various daemons like cron,dbus etc, and also various programs like emacs, iceweasel (firefox), pidgin, xterm, xpdf.
$ pstree
init-+-cron
|-daemon
|-another-daemon
|-emacs
|-getty
|-login---bash---links
|-login---bash---startx---xinit-+-Xorg
| `-fluxbox-+-bash-+-firefox-bin---7*[{firef+
| | `-pidgin
| `-xterm---bash-+-pstree
| `-xpdf.bin
|-preload
|-syslogd
`-udevd
You might ask me why I don't use screen instead of nohup ? Well, I tend not to use screen for those commands that don't need my supervision. I might run my rss reader raggle under screen but not commands like updating locate databases, downloading packages or files using bittorrent I leave it to nohup.