How to add timestamp to STDERR redirection

后端 未结 13 2330
感情败类
感情败类 2020-11-28 05:10

In bash/ksh can we add timestamp to STDERR redirection?

E.g. myscript.sh 2> error.log

I want to get a timestamp written on the log too.

相关标签:
13条回答
  • 2020-11-28 05:49

    This thing: nohup myscript.sh 2> >( while read line; do echo "$(date): ${line}"; done > mystd.err ) < /dev/null &

    Works as such but when I log out and log back in to the server, it does not work. that is mystd.err stop getting populated with stderr stream even though my process (myscript.sh here) still runs.

    Does someone know how to get back the lost stderr in the mystd.err file back?

    0 讨论(0)
提交回复
热议问题