LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   close terminal mean close background process? (https://www.linuxquestions.org/questions/linux-general-1/close-terminal-mean-close-background-process-566205/)

Niceman2005 07-03-2007 02:00 AM

close terminal mean close background process?
 
Dear frens,

In moving a process to background. What i di was to type bg or Ctrl+z from the terminal.
But when i closed the terminal that also terminates the background process. How to I ensure that the background process are not terminated even after i close the terminal?
thanks

b0uncer 07-03-2007 02:08 AM

If you kill a process, all it's child processes should die too, that's the rule. So if you start a program (fore- or background) from a terminal, it becomes the child of that terminal and when you close the terminal, it's process dies and all the childs as well.

Easy solution: use a program called screen which enables you to run programs, detach them, log out of the whole machine if you like and when you return, just re-attach the session. Probably just what you're asking, right?

Niceman2005 07-03-2007 02:48 AM

Thanks a lot friend!

asd0z 08-17-2009 08:13 AM

Quote:

Originally Posted by Niceman2005 (Post 2808680)
How to I ensure that the background process are not terminated even after i close the terminal?
thanks

Use jobs to see bg processes.
Use disown to make child process free.

asd0z 08-17-2009 08:13 AM

See more at Process detaching in linux

chrism01 08-17-2009 07:53 PM

Just use nohup

nohup myprog &

tomtom85 05-27-2010 10:46 AM

Quote:

Originally Posted by chrism01 (Post 3647286)
Just use nohup

nohup myprog &

nohup redirects all the output to a new file named nohup.out. if you are running something big, it can get nasty

dasy2k1 05-27-2010 02:58 PM

easiest i think is to use disown...

eg when i want to play an open GL game i need to change window manager and i do it like this
Code:

metacity --replace &
disown

the first command runs metactity as a background process, (sitll visible in jobs) but the second detatches it totally from the xterm i use


All times are GMT -5. The time now is 02:36 PM.