我正在编写一个bash脚本来帮助记录我们在AWS上运行的系统。
它最终运行的命令的简化版本是aws logs tail | grep "term"
。一切正常,但是当我用ctrl + c关闭日志流时,我得到了以下错误:
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>
BrokenPipeError: [Errno 32] Broken pipe
我可以防止这种情况发生吗,或者它是应该在aws logs
脚本中捕获的东西吗?
发布于 2021-11-03 16:28:03
在aws
为expected to handle的Python中,这是一个错误特性。但是,如果您只是希望不显示错误,则可以这样做:
aws logs tail | tee -p /dev/null | grep "term"
https://stackoverflow.com/questions/67768952
复制