title: Ending tail -f started in a shell script
body: <p>I have the following.</p>
  
  <ol>
  <li>A Java process writing logs to the stdout </li>
  <li>A shell script starting the Java process </li>
  <li>Another shell script which executes the previous one and redirects the log</li>
  <li>I check the log file with the <code>tail -f</code> command for the success message.</li>
  </ol>
  
  <p>Even if I have exit 0 in the code I cannot end the <code>tail -f</code> process.</p>
  
  <p>Which doesn't let my script to finish. Is there any other way of doing this in Bash?</p>
  
  <p>The code looks like the following.</p>
  
  <pre><code>function startServer() {
    touch logfile
    startJavaprocess &gt; logfile &amp;
  
    tail -f logfile | while read line 
    do
      if echo $line | grep -q 'Started'; then
        echo 'Server Started'
        exit 0
      fi
    done
  }
  </code></pre>