【问题标题】:Add timestamp to sdterr?将时间戳添加到标准错误?
【发布时间】:2020-09-18 15:15:04
【问题描述】:

我有一个由 bash 脚本启动的应用程序。我将 stderr 和 stdout 重定向到不同的文件:

./app >> /home/user/logs/debug.log 2>>/home/user/logs/debug.err &

我需要为 stderr 行添加时间戳。 我该怎么做?

【问题讨论】:

    标签: bash unix-timestamp moreutils


    【解决方案1】:

    看看这个

    ./app >> /home/user/logs/debug.log 2> >( while read line; do echo "$(date): ${line}"; done > /home/user/logs/debug.err )
    

    【讨论】:

    • 我有一个语法错误,因为我需要在行尾添加'&'才能在后台运行
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-21
    • 2010-10-26
    • 2014-03-18
    • 1970-01-01
    • 2019-10-25
    • 2015-03-09
    相关资源
    最近更新 更多