title: Grep apache server 500 errors to a separate file
body: <p>Hi I am trying to tail apache access logs and copy the errors to another file. I tried below options and all are working in command line but when triggered from a script they are not working.</p>
  
  <p>I understand the tail command is not exiting and so there is no output. But not sure how to overcome this.</p>
  
  <pre><code>/usr/bin/tail -f /apps/apache/logs/access_log | grep -h "HTTP\/1.1\" 50." &gt;&gt; /tmp/log_error_capture.txt
   grep -m 1 "HTTP\/1.1\" 50." &lt;(tail -f /apps/apache/logs/access_log)
  ( tail -f -n0 /apps/apache/logs/access_log &amp; ) | grep -q "HTTP\/1.1\" 50." &gt; /tmp/log_error_capture.txt
  tail -f logfile |grep -m 1 "HTTP\/1.1\" 50." | xargs echo "" &gt;&gt; logfile \;
  </code></pre>
  
  <p>Can someone suggest a better way to grep the errors. Please.</p>