title: Two bash jobs executed at the same time
body: <p>I am using Python to execute an external program by simply using Python's "os" library:</p>
  
  <pre><code>os.system("./script1") # script1 generates several log files and the most important for me is "info.log" !
  os.system("./script2") # script2 uses the output from script1
  </code></pre>
  
  <p>The problem is that those scripts are in 50000 element "for loop" and "script1" needs at least 2 min to finish its job (it has fixed time duration)
  In the first 1-2 sec I can find out whether I need the output data or not by looking in to the "info.log" file. However, as "script1" is an already compiled program and I can't modify it, I have to wait until it finishes.</p>
  
  <p>I was thinking about a method in Bash that allows me to run two processes at the same time:
  one is to start <code>./script1</code> and the other is to monitor any change in the "info.log" file...<br>
  If "info.log" has been updated or changed in size, then the second script should terminate both processes.</p>
  
  <p>Something like:</p>
  
  <pre><code>os.system("./mercury6 1 &gt; ./energy.log 2&gt;/dev/null &amp; sleep 2 &amp; if [ $(stat -c %s ./info.log) -ge 1371]; then kill %1; else echo 'OK'; fi")
  </code></pre>
  
  <p>&ndash; which does not work...</p>
  
  <p>Please, if someone knows a method, let me know!</p>