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.
I understand the tail command is not exiting and so there is no output. But not sure how to overcome this.
/usr/bin/tail -f /apps/apache/logs/access_log | grep -h "HTTP\/1.1\" 50." >> /tmp/log_error_capture.txt
grep -m 1 "HTTP\/1.1\" 50." <(tail -f /apps/apache/logs/access_log)
( tail -f -n0 /apps/apache/logs/access_log & ) | grep -q "HTTP\/1.1\" 50." > /tmp/log_error_capture.txt
tail -f logfile |grep -m 1 "HTTP\/1.1\" 50." | xargs echo "" >> logfile \;
Can someone suggest a better way to grep the errors. Please.