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.
ps -axjfto view running processes. I think you java process is running but not printing anything (yet).nohup sh datagenerate.sh > datagenerate.log && after 2 seconds I hit enter, then it's showing process is Done. I checked whether it's running & result was it didn't show any process with that id. My java process is running & it's printing values.(I'm sure about it & verified as well)