LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 03-25-2005, 08:24 AM   #1
pfaendtner
Member
 
Registered: Nov 2003
Posts: 57

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


Hi,

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, 08:55 AM   #2
ksgill
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, 10:44 AM   #3
pfaendtner
Member
 
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, 10:53 AM   #4
visaris
Member
 
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.
Code:
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, 11:09 AM   #5
pfaendtner
Member
 
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, 11:34 AM   #6
ralvez
Member
 
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.

Rick
 
  


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 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 03:53 PM
KDE hangs at logout patufet99 Linux - Newbie 3 12-04-2005 10:42 PM
logout from console hangs slice Linux - Newbie 8 02-22-2005 02:07 PM
KDE 3.3.1 hangs on logout, only for root davidsrsb Slackware 10 12-08-2004 01:41 PM
Keeping a process running after shell logout abboq Linux - Software 5 09-01-2004 06:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:27 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration