Running a command via SSH

Fraser Campbell fraser-eicrhRFjby5dCsDujFhwbypxlwaOVQ5f at public.gmane.org
Sun May 2 16:54:30 UTC 2004


On Sunday 02 May 2004 12:24, Sidney Shapiro wrote:

> I often SSH into a remote server and run commands. Is there something I
> can do to keep those commands running after I log out or close the SSH
> window?

I suspect that you are experiencing hangs on exit from ssh.  stdin, stderr and 
stdout can be problematic so redirect those to /dev/null (or elsewhere):

  command > /dev/null 2>&1 < /dev/null &

If you want to launch the commands remotely (without an interactive login) 
then some variation on these should work for you:

  ssh -f hostname command

  ssh hostname command \&

  ssh hostname command \> /dev/null 2\>\&1 \< /dev/null \&

Not the backgrounding (&) and the redirections must be done on the remote end 
so they must be quoted so that they aren't interpreted by your local shell.  

The openssh faq talks about the hang on exit problem, they might have other 
suggestions as well.

-- 
Fraser Campbell <fraser-Txk5XLRqZ6CsTnJN9+BGXg at public.gmane.org>                 http://www.wehave.net/
Georgetown, Ontario, Canada                               Debian GNU/Linux
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list