Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
how to dissassociate proccess with the shell?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
fusama
n00b
n00b


Joined: 31 Aug 2005
Posts: 21
Location: USA

PostPosted: Tue Aug 12, 2008 7:22 pm    Post subject: how to dissassociate proccess with the shell? Reply with quote

Here's what I want to do. I want to ssh (via putty) into my gentoo box and start some long-running job, say "emerge kde-meta" and then close putty and have the job keep running (until it completes, obviously).

I have found no combination of &, nohup, disown, or disown -h that would do this. (I was using bash if it matters) The best I did was that one combination (sorry, don't remember which one) that would get the job to not die when putty closed, but it stopped executing, which doesn't do me much good. (I was using a second ssh connection (via putty) to watch what was going on when I closed the first ssh session). With all other combinations I tried the process died when putty closed.

It seems like this is something that should be possible, but I'm at a loss as to how to do it.

Thanks.
Back to top
View user's profile Send private message
timeBandit
Bodhisattva
Bodhisattva


Joined: 31 Dec 2004
Posts: 2719
Location: here, there or in transit

PostPosted: Tue Aug 12, 2008 7:28 pm    Post subject: Reply with quote

nohup command & does this. The process will block if it needs any input however (e.g., emerge -a would be bad).

Another, far more flexible option: app-misc/screen.
_________________
Plants are pithy, brooks tend to babble--I'm content to lie between them.
Super-short f.g.o checklist: Search first, strip comments, mark solved, help others.
Back to top
View user's profile Send private message
termite
Guru
Guru


Joined: 06 May 2007
Posts: 466

PostPosted: Tue Aug 12, 2008 9:02 pm    Post subject: Reply with quote

emerge screen, then run something like
Code:
screen -S myprocess
It will open a shell, in which you can start whatever you like. When you're ready to disconnect, press Ctrl-a, then d. If you want to reconnect to the process, run
Code:
screen -r myprocess
Screen can do a lot more than that, but that will get you started.
Back to top
View user's profile Send private message
beandog
Bodhisattva
Bodhisattva


Joined: 04 May 2003
Posts: 2072
Location: /usa/utah

PostPosted: Tue Aug 12, 2008 9:24 pm    Post subject: Reply with quote

you don't have to name the session if you want, anyway.

just do screen, then detach it. then screen -r or screen -x to retach it, using the session name if there's more than one.

anyway, like everyone has said ... lots of ways to use screen. ++
_________________
If it ain't broke, tweak it. dvds | blurays | blog | wiki
Back to top
View user's profile Send private message
Mad Merlin
Veteran
Veteran


Joined: 09 May 2005
Posts: 1155

PostPosted: Wed Aug 13, 2008 12:33 am    Post subject: Reply with quote

Code:
screen
is the best option, but you can also use
Code:
setsid
.
_________________
Game! - Where the stick is mightier than the sword!
Back to top
View user's profile Send private message
ddriver
n00b
n00b


Joined: 24 Feb 2005
Posts: 67

PostPosted: Wed Aug 13, 2008 9:45 am    Post subject: Reply with quote

Another way is to run the command using "batch". batch is just an alias for "at now".
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum