Clean way of launching a shell script in background from Jenkins
<p>What's the proper way to launch a script from jenkins, don't get the build hanging, and leave the process running? I can't seem to get it to work. Either the script doesn't run or the build hangs.</p>

<p>If I put in the build's "Execute shell" step <code>bash relaunch.sh &amp;</code> or <code>relaunch.sh &gt; output.log &amp;</code> or <code>nohup bash relaunch.sh &amp;</code>, 
nothing happens; build finishes, but the process doesn't run. I guess it can be related to Jenkins waiting for the <a href="https://stackoverflow.com/a/30627285/5961990">error pipe to close</a>.</p>

<p>If I do
<code>nohup bash relaunch.sh 2&gt;&amp;1 &gt; output.log</code>  as suggested <a href="https://stackoverflow.com/questions/28319984/how-can-i-call-shell-script-to-start-a-backend-java-process">here</a>, the output is properly redirected, but the build hangs (doesn't finish), and the process dies when I kill the build.</p>

<p>Adding <code>export BUILD_ID=dontKillMe</code>, as suggested <a href="https://stackoverflow.com/questions/14584933/jenkins-kills-jboss-server-when-job-finishes">here</a>, <a href="https://serverfault.com/questions/502593/starting-a-forever-process-in-a-jenkins-build-step">here</a>, and <a href="https://stackoverflow.com/questions/9567441/jenkins-seems-to-be-the-target-for-nohup-in-a-script-started-via-ssh-how-can-i">here</a>, either to the "Execute shell" step or the script itself doesn't help either. The build hangs and the process dies when I kill the build. Needless to say, my knowledge of linux is very limited.</p>

<p>How do people do this in a clean way?</p>