title: Run bash script loop in background which will write result of jar command to file
body: <p>I'm novice to running bash script. (you can suggest me, if title I've given is incorrect.)
  I want to run a jar file using bash script in loop. Then it should write the output of jar command into some file.
  Bash file <strong>datagenerate.sh</strong></p>
  
  <pre><code>#!/bin/bash
  echo Total iterations are 500
  for i in {1..500}
  do
     the_output="$(java -jar data-generator.jar 10 1 mockData.csv data_200GB.csv)"
     echo $the_output
     echo Iteration  $i processed
  done
  no_of_lines="$(wc -l data_200GB.csv)"
  echo "${no_of_lines}"
  </code></pre>
  
  <p>I'm running above script using command <code>nohup sh datagenerate.sh &gt; datagenerate.log &amp;</code>. As I want to run this script in background, so that even I log out from <code>ssh</code> it should keep running &amp; output should go into <code>datagenerate.log</code>.</p>
  
  <p>But when I ran above command and hit enter or close the terminal it ends the process. Only <code>Total iterations are 500</code> is getting logged into output file.</p>
  
  <p>Let me know what I'm missing. I followed following two links to create above shell script: <a href="https://stackoverflow.com/questions/20166919/how-to-run-jar-file-assgin-to-variable-and-echo-it-out-in-shell-script">link-1</a> &amp; <a href="https://stackoverflow.com/questions/18612603/redirecting-output-of-bash-for-loop">link2</a>.</p>