View previous topic :: View next topic |
Author |
Message |
gfunkmonk Tux's lil' helper
Joined: 10 Jul 2002 Posts: 129 Location: Freelandville, IN
|
Posted: Tue Sep 03, 2002 1:31 pm Post subject: Processes and SSH |
|
|
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 |
|
|
Naan Yaar Bodhisattva
Joined: 27 Jun 2002 Posts: 1549
|
Posted: Tue Sep 03, 2002 1:48 pm Post subject: |
|
|
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 |
|
|
ebichu Apprentice
Joined: 03 Jul 2002 Posts: 231 Location: Manchester, England
|
Posted: Tue Sep 03, 2002 4:54 pm Post subject: |
|
|
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 |
|
|
Valen Apprentice
Joined: 18 Aug 2002 Posts: 197 Location: Toronto, Ontario, Canada
|
Posted: Tue Sep 03, 2002 5:11 pm Post subject: |
|
|
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 |
|
|
Naan Yaar Bodhisattva
Joined: 27 Jun 2002 Posts: 1549
|
Posted: Wed Sep 04, 2002 1:41 am Post subject: |
|
|
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 |
|
|
Valen Apprentice
Joined: 18 Aug 2002 Posts: 197 Location: Toronto, Ontario, Canada
|
Posted: Wed Sep 04, 2002 5:13 am Post subject: |
|
|
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 |
|
|
Naan Yaar Bodhisattva
Joined: 27 Jun 2002 Posts: 1549
|
Posted: Wed Sep 04, 2002 12:50 pm Post subject: |
|
|
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 |
|
|
|