title: Run a background job from Gradle
body: <p>I've created a task starting a remote job like</p>
  <pre><code>task mytask(type: Exec) {
      commandLine 'ssh'
      args '-f -l me myserver ./start'.split(' ')
  }
  </code></pre>
  <p>and it works, however, it seems to wait for the job to terminate. But it never terminates and it shouldn't.</p>
  <p>Doing the same from the command line works: Because of the <code>-f</code> switch the <code>ssh</code> command gets executed in the background.</p>
  <p>I've tried to add <code>'&gt;&amp;' /dev/null</code> (csh stdout and stderr redirect) to the command line, but without any success. Also the obvious <code>&amp;</code> did nothing. I also extracted the command line into a script, and it's always the same: Gradle waits for termination.</p>
  <h2>Solution</h2>
  <p>I've solved it by using a script and redirecting both stdout and stderr in the script. My problem came from confusing redirections... by passing <code>'&gt;&amp;' /dev/null</code> I redirected the streams on the remote computer, but what was needed was a redirection on the local one (i.e., without putting the redirection operator in quotes).</p>