
다음 명령을 사용하여 아래 오류 메시지(총 3줄)를 얻었습니다.
$ tail -f -n 0 error.log | grep -A2 --line-buffered "Internal server error"
! @79884flo2 - Internal server error, for (GET) [/] ->
play.api.UnexpectedException: Unexpected exception[Missing: No configuration setting found for key init.default]
로그를 한 줄로 결합하는 몇 가지 기술을 시도하고 성공했습니다.
xargs
tail -f -n 0 error.log | grep -A2 --line-buffered "error" | xargs -I @ printf "%s" "@"
awk
tail -f -n 0 error.log | grep -A2 --line-buffered "error" | awk '{ printf("%s ", $0); }'
paste
:tail -f -n 0 error.log | grep -A2 --line-buffered "error" | paste -d " " - - -
telegram-notify
다음으로 다음 명령을 사용하여 출력을 텔레그램으로 보내고 싶습니다 .
telegram-notify --error --title "<title>" --text "<output from above command goes here>"
현재 제가 할 수 있는 최선은 xargs
텔레그램을 사용하여 로그의 각 줄을 개별적으로 보내는 것입니다.
tail -f -n 0 error.log | grep -A2 --line-buffered "error" | xargs -L 3 -I {} telegram-notify --error --title "<title>" --text "{}"
조언해주세요:
위에서 시도한 세 가지
xargs
, , 명령awk
중 어떤 명령을paste
사용하여 줄을 결합해야 합니까?xargs
//에서 명령 옵션으로 출력을 추가로 파이프하거나 전달하는 방법awk
paste
telegram-notify
--text