Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Possible Duplicate:
How do I prevent a script from terminating when the shell exits?

I use gnome-terminal, and I run emacs under the terminal in the background by executing emacs &, but after I close the terminal, emacs is also closed. How can I avoid this behavior? I know that emacs is a child process of the shell.

share|improve this question

marked as duplicate by andcoz, manatwork, Michael Mrozek Jun 6 '12 at 15:45

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2  
unix.stackexchange.com/questions/479/… and many other similar questions you can find here. –  rush Jun 6 '12 at 14:29
add comment

2 Answers 2

Check out GNU Screen. You can run something in the screen, then detach and disconnect and the script/program continues to run.

Link: http://www.gnu.org/software/screen/

Screen can be found in most distros. Ubuntu has a forked "Super" version of it available as well.

share|improve this answer
add comment

You can start emacs using the nohup command. nohup will run a command immune to hangups, with output to a non-tty

nohup emacs &

This will prevent the emacs process from terminating when the shell closes and the controlling terminal is destroyed.

You can get more information about nohup from info coreutils 'nohup invocation'

This is a nice discussion about nohup, disown, and &.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.