[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Starting background process in ssh session

On Thu, Sep 01, 2005 at 05:33:28PM -0400, Roberto C. Sanchez wrote:
> I occasionally log into a machine remotely and start a process in the
> background:
> command &
> However, when I log out of the machine, the ssh process on my local
> machine blocks.  I guess that it is becuase the remote still has jobs
> running.  Is there a way to get it start the process in the background
> and then detach from the shell?  I have already tried this:

This is often caused because the process still has a file descriptor (FD)
referencing the tty.  Ssh doesn't like to terminate when this occurs,
because there's a chance that the FD could still be required.  If this 
is the case, then you probably just need to redirect the usual 
suspects... stdin, stdout, and/or stderr.  Something like:

   $ command </dev/null >&0 2>&0 &

It may not be necessary to redirect all of them, but that will probably 
require some experimentation to determine.  You may want to consider 
running your command under "nohup" as well, to protect it from the loss 
of your session.

Attachment: signature.asc
Description: Digital signature

Reply to: