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? |
Does it happen with all the programs or just one or two particular ones? What program are you trying to run?
|
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...
|
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 |
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.
|
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 |
All times are GMT -5. The time now is 08:21 PM. |