title: How to get nohup proccess id in bash script
body: <p>I have a bash script to run a command via nohup, I need the proccess id in the script.</p>
  
  <p>I tried this:</p>
  
  <pre><code>#!/bin/bash
  nohupResult=$((nohup mycommand &gt; nohup.out &amp;) 2&gt;&amp;1)
  echo $nohupResult
  exit 0
  </code></pre>
  
  <p>But the <code>$nohupResult</code> is null.</p>
  
  <p>I tried also this:</p>
  
  <pre><code>nohupResult=`nohup mycommand &gt; nohup.out &amp;`
  </code></pre>
  
  <p>But the <code>$nohupResult</code> is null either.</p>
  
  <p>If I run the command <code>nohup mycommand &gt; nohup.out &amp;</code> in shell, I will get some outputs like:</p>
  
  <pre><code>[1] 447019
  </code></pre>
  
  <p>But how could I get the process id in the script?</p>
  
  <p>Any help would be much appreciated.</p>