How can I make the Ant task "SSHExec" run a command and exit before it's completed?

StackOverflow https://stackoverflow.com/questions/23413089

  •  13-07-2023
  •  | 
  •  

Question

I have an ant build script that connects to a remote server and kicks off a local build using SSHExec. This build takes approximately 1 minute and it sends me an email when it's completed, but the ant task I have:

<sshexec
   host="${deploy.host}"
   username="${deploy.username}"
   trust="true"
   keyfile="${user.home}/.ssh/id_rsa"
   command="~/updateGit.sh"/>

Will wait until the script is completed. I tried passing a & like so (I assume I have to escape it in a build.xml):

<sshexec
   host="${deploy.host}"
   username="${deploy.username}"
   trust="true"
   keyfile="${user.home}/.ssh/id_rsa"
   command="~/updateGit.sh &amp;"/>

But this doesn't seem to make a difference. In case this extra detail helps anyone, the script generates a lot of output and a slow internet connection can cause the script to take a lot longer (as it's output is being piped back, the assumption with this approach is that I only care about the output after its done, so if I pack it up into an email I can monitor my inbox as builds get kicked off, basically it's a poor-man's Continuous Integration)

Was it helpful?

Solution

Using information from this answer (and the nohup command) I updated my task as follows:

<sshexec
  host="${deploy.host}"
  username="${deploy.username}"
  trust="true"
  keyfile="${user.home}/.ssh/id_rsa"
  command="nohup ~/updateGit.sh &gt; /dev/null 2&gt; error.log &lt; /dev/null &amp;"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top