Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Processes and SSH
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
gfunkmonk
Tux's lil' helper
Tux's lil' helper


Joined: 10 Jul 2002
Posts: 129
Location: Freelandville, IN

PostPosted: Tue Sep 03, 2002 1:31 pm    Post subject: Processes and SSH Reply with quote

Is there a way to use ssh to remotly access your machine, then run a command and close the connection and have the command keep running?
Back to top
View user's profile Send private message
Naan Yaar
Bodhisattva
Bodhisattva


Joined: 27 Jun 2002
Posts: 1549

PostPosted: Tue Sep 03, 2002 1:48 pm    Post subject: Reply with quote

As long as you redirect stdin, stdout and stderr to files or /dev/null and background it, you should be able to do this. E.g.,
Code:

sleep 30 < /dev/null >& /dev/null &
Back to top
View user's profile Send private message
ebichu
Apprentice
Apprentice


Joined: 03 Jul 2002
Posts: 231
Location: Manchester, England

PostPosted: Tue Sep 03, 2002 4:54 pm    Post subject: Reply with quote

If you want to monitor the output or enter input occasionally, you can use the screen utility if it is installed. This emulates a terminal within your terminal via the magic of pseudo-ttys and a curses library, but the real magic is that you can detach from the emulated terminal, leaving whatever's running running and reattach it later. About the only thing that won't work is your real terminal's scrollback buffer.
_________________
Ebichu wa chiizu ga daisuki dechu!
Back to top
View user's profile Send private message
Valen
Apprentice
Apprentice


Joined: 18 Aug 2002
Posts: 197
Location: Toronto, Ontario, Canada

PostPosted: Tue Sep 03, 2002 5:11 pm    Post subject: Reply with quote

I use the 'nohup' command and background it. I've never tried just reassigning all input and output before but in case what Naan Yaar suggested doesn't work you could give this a try.

(edit: grammar)


Last edited by Valen on Wed Sep 04, 2002 5:09 am; edited 1 time in total
Back to top
View user's profile Send private message
Naan Yaar
Bodhisattva
Bodhisattva


Joined: 27 Jun 2002
Posts: 1549

PostPosted: Wed Sep 04, 2002 1:41 am    Post subject: Reply with quote

nohup on its own will not reassign stdin. This will cause ssh to wait. You could do:
Code:

nohup <command> < /dev/null &

instead of redir'ing stdout/err.
Valen wrote:
I use the 'nohup' command and background it. I've never tried just reassigned all input and output before but in case what Naan Yaar suggested doesn't work you could give this a try.
Back to top
View user's profile Send private message
Valen
Apprentice
Apprentice


Joined: 18 Aug 2002
Posts: 197
Location: Toronto, Ontario, Canada

PostPosted: Wed Sep 04, 2002 5:13 am    Post subject: Reply with quote

Naan Yaar wrote:
nohup on its own will not reassign stdin. This will cause ssh to wait. You could do:
Code:

nohup <command> < /dev/null &

Yes, I didn't think of that. But it does seem to work if the process requires no input (at least it has for me so far).
Out of curiousity is that all nohup does to keep the process alive (reassign outputs I mean)?
Back to top
View user's profile Send private message
Naan Yaar
Bodhisattva
Bodhisattva


Joined: 27 Jun 2002
Posts: 1549

PostPosted: Wed Sep 04, 2002 12:50 pm    Post subject: Reply with quote

Yeah... it redirects stdout and stderr to a file, nices the job, makes it ignores SIGHUPs.
Valen wrote:
...
Yes, I didn't think of that. But it does seem to work if the process requires no input (at least it has for me so far).
Out of curiousity is that all nohup does to keep the process alive (reassign outputs I mean)?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo 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