title: My bash script locks the file while Java needs to read it
body: <p>I have a bash script in Linux (CentOS) that redirects output to a file. It takes a few minutes to run:</p>
  
  <pre><code>./myBashScript.sh &gt;&gt; file.csv
  </code></pre>
  
  <p>I have a java application that tries to <strong>read</strong> the file (only read) for further processing:</p>
  
  <pre><code>    File file = new File("file.csv");
              Scanner input = new Scanner(file);
              while (input.hasNextLine()) {
                  String line = input.nextLine();
                  // do something...
              }
  </code></pre>
  
  <p>These processes are on <code>Crontab</code>. It works all fine, but apparently whenever the bash script is redirecting the output to the file, the Java app can not read it. The logs shows <code>"File not found"</code> exception!</p>
  
  <p>Is the file locked?! How can I fix the problem?</p>