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 datagenerate.sh
#!/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}"
I'm running above script using command nohup sh datagenerate.sh > datagenerate.log &
. As I want to run this script in background, so that even I log out from ssh
it should keep running & output should go into datagenerate.log
.
But when I ran above command and hit enter or close the terminal it ends the process. Only Total iterations are 500
is getting logged into output file.
Let me know what I'm missing. I followed following two links to create above shell script: link-1 & link2.