【问题标题】:How to prevent BrokenPipeError when grepping aws logs tail output?grepping aws日志尾输出时如何防止BrokenPipeError?
【发布时间】:2021-08-18 11:27:43
【问题描述】:

我正在编写一个 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 脚本中捕获它?

【问题讨论】:

  • 这是应该在 aws 日志脚本中捕获的内容。

标签: bash aws-cli


【解决方案1】:

awsexpected to handle,这是 Python 中的一个错误功能。但是,如果您只是希望不显示错误,您可以这样做:

 aws logs tail | tee -p /dev/null | grep "term"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-08-16
    • 2014-12-28
    • 1970-01-01
    • 1970-01-01
    • 2014-08-10
    • 1970-01-01
    相关资源
    最近更新 更多