Open wada811 opened 5 years ago
tail でログを監視してみたが、関係ない情報が多いため grep で絞り込みたい。
tail -F access.log | grep "Status: 500" とすると grep がバッファリングしてしまうため、 行ごとにバッファリングしてリアルタイムに出力する。
tail -F access.log | grep "Status: 500"
grep
grep の --line-buffered オプションを使う。
--line-buffered
上記の例では、以下のコマンドを実行する。
tail -F access.log | grep --line-buffered "Status: 500"
grep(1) BSD General Commands Manual
grep [--line-buffered] Force output to be line buffered. By default, output is line buffered when standard output is a terminal and block buffered otherwise.
Why
tail でログを監視してみたが、関係ない情報が多いため grep で絞り込みたい。
What
tail -F access.log | grep "Status: 500"
とするとgrep
がバッファリングしてしまうため、 行ごとにバッファリングしてリアルタイムに出力する。How
grep
の--line-buffered
オプションを使う。上記の例では、以下のコマンドを実行する。
Ref
grep(1) BSD General Commands Manual