LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 07-03-2007, 02:00 AM   #1
Niceman2005
Member
 
Registered: Nov 2004
Distribution: Fedora Core 2
Posts: 330

Rep: Reputation: 30
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
 
Old 07-03-2007, 02:08 AM   #2
b0uncer
Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
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?
 
Old 07-03-2007, 02:48 AM   #3
Niceman2005
Member
 
Registered: Nov 2004
Distribution: Fedora Core 2
Posts: 330

Original Poster
Rep: Reputation: 30
Thanks a lot friend!
 
Old 08-17-2009, 08:13 AM   #4
asd0z
LQ Newbie
 
Registered: Aug 2009
Posts: 13

Rep: Reputation: 0
Quote:
Originally Posted by Niceman2005 View Post
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.
 
Old 08-17-2009, 08:13 AM   #5
asd0z
LQ Newbie
 
Registered: Aug 2009
Posts: 13

Rep: Reputation: 0
See more at Process detaching in linux
 
Old 08-17-2009, 07:53 PM   #6
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,269

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
Just use nohup

nohup myprog &
 
Old 05-27-2010, 10:46 AM   #7
tomtom85
LQ Newbie
 
Registered: May 2010
Posts: 1

Rep: Reputation: 0
Quote:
Originally Posted by chrism01 View Post
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

Last edited by tomtom85; 05-31-2010 at 10:48 AM.
 
Old 05-27-2010, 02:58 PM   #8
dasy2k1
Member
 
Registered: Oct 2005
Location: 127.0.0.1
Distribution: Ubuntu 12.04 X86_64
Posts: 956

Rep: Reputation: 34
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
background jobs killed when I close the xterm lawrence_lee_lee Linux - Software 5 06-11-2007 12:31 AM
Processes close with terminal Xyem Linux - Software 4 07-08-2006 01:44 PM
How to launch an app in terminal, & keep it running after I close terminal? kornerr Linux - General 7 06-24-2006 05:54 PM
can you close a cd drive from the terminal? dr_zayus69 Linux - Hardware 4 12-01-2004 08:30 PM
what happens if I close ssh terminal ? juanb Linux - General 1 09-17-2004 05:15 PM


All times are GMT -5. The time now is 02:51 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration