Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-25-2005, 07:24 AM   #1
Registered: Nov 2003
Posts: 57

Rep: Reputation: 15
running in background hangs on shell logout


When I have a terminal window open (or I'm connected to another computer via ssh) and I submit programs to run in the background with &, the shell always hangs when I type "exit". How can I fix this?
Old 03-25-2005, 07:55 AM   #2
Senior Member
Registered: Apr 2003
Location: Toronto, Canada
Distribution: Ubuntu Jaunty (9.04)
Posts: 1,044

Rep: Reputation: 45
Does it happen with all the programs or just one or two particular ones? What program are you trying to run?
Old 03-25-2005, 09:44 AM   #3
Registered: Nov 2003
Posts: 57

Original Poster
Rep: Reputation: 15
I run some computational chemistry software and in-house c-codes (ode solvers, etc). Pretty much anytime I've got something backgrounded and exit my shell it hangs...
Old 03-25-2005, 09:53 AM   #4
Registered: Dec 2004
Distribution: gentoo
Posts: 190

Rep: Reputation: 30
Yeah, the shell is waiting for all the jobs to finish. I'm not sure how to get it to stop doing that. If you kill off all the jobs before you try an log out you shouldn't have any problems. Type jobs to list all the current jobs.
foo@bar foo $ jobs
[1]   Running                 ddd &
[2]-  Running                 gqview &
[3]+  Running                 xmms &
foo@bar foo $
They bring them to the forgraound with "fg 1", "fg 2", "fg 3", etc, and kill them with ^C. You should be able to log out fine after that.
Old 03-25-2005, 10:09 AM   #5
Registered: Nov 2003
Posts: 57

Original Poster
Rep: Reputation: 15
The thing is I often run jobs in the background and logout because they take several days. We use 4 or 5 workstations for running code, etc and it's common to launch a job and then go work somewhere else. Typically I have two shells open then in another window I kill the ssh which has hung. It gets the job done, I just think there has to be a better way.
Old 03-25-2005, 10:34 AM   #6
Registered: Oct 2003
Location: Canada
Distribution: ArchLinux && Slackware 10.1
Posts: 298

Rep: Reputation: 30
The solution to your problem is a command called: screen
Say that you want to run something in a particular system like a heavy duty number crunching program and that it would take too long to wait for it to finish ... sounds like your case?
OK. This is what you do:
1.Log over SSH into the system
2. Issue the command screen -t number_crunching
3. Start the program that does all the magic with the numbers
4. press Ctrl+a
5. press d
6. log off that machine

When you are ready (say 1 or 2 hrs later) you log in again into that system (using ssh) then your type:
screen -p number_crunching -r
and you are back to the exact same thread you left off earlier, but you see all messages that the math program wrote to the console and if it is done working you will see it, otherwise, if it needs to for for a bit more you type Ctrl+a and press "d" again and let it "cook" for a bit more.

I must say this program rocks ! I use it all the time.

Hope this will help you too.



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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Put a process in background and logout esasse Linux - Newbie 11 03-28-2012 02:53 PM
KDE hangs at logout patufet99 Linux - Newbie 3 12-04-2005 09:42 PM
logout from console hangs slice Linux - Newbie 8 02-22-2005 01:07 PM
KDE 3.3.1 hangs on logout, only for root davidsrsb Slackware 10 12-08-2004 12:41 PM
Keeping a process running after shell logout abboq Linux - Software 5 09-01-2004 05:58 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:07 PM.

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