title: pass custom env variable to nohup
body: <p>How can I make the below code work? I want to pass <code>custom_var</code> value to the <code>command</code> script.</p>
  
  <pre><code>$ command="echo $custom_var"
  $ custom_var=myValue nohup $command &gt; log.txt &amp;&amp; cat log.txt 
  $ # WRONG. Should be 'myValue'
  </code></pre>
  
  <p><a href="https://unix.stackexchange.com/questions/308370/how-can-i-set-environment-variables-for-a-program-executed-using-nohup">This</a> doesn't seems to work. The above output should print "myValue". Also tried:</p>
  
  <pre><code>$ command="echo \$custom_var"
  $ custom_var=myValue nohup $command &gt; log.txt &amp;&amp; cat log.txt 
  $ $custom_var # WRONG. Should be 'myValue'
  </code></pre>
  
  <p>Thank you</p>