Getting ssh to execute a command in the background on target machine

Posted by dagorym on Stack Overflow See other posts from Stack Overflow or by dagorym
Published on 2008-08-26T22:55:58Z Indexed on 2010/05/14 2:14 UTC
Read the original article Hit count: 283

Filed under:
|
|
|

This is a follow-on question to the How do you use ssh in a shell script? question. If I want to execute a command on the remote machine that runs in the background on that machine, how do I get the ssh command to return? When I try to just include the ampersand (&) at the end of the command it just hangs. The exact form of the command looks like this:

ssh user@target "cd /some/directory; program-to-execute &"

Any ideas? One thing to note is that logins to the the target machine always produce a text banner and I have ssh keys set up so no password is required.

© Stack Overflow or respective owner

Related posts about bash

Related posts about ssh