douyan8027
2015-01-24 12:26 阅读 41

Debian:如何将错误消息写入文件?

I wrote a websocket server with go, running on Debian. Now I have a very long panic message and I want to write it to a file

./server > err

writes only the normal output. Error messages still appear on stdout.

How can I redirect them?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    douluohan3403 douluohan3403 2015-01-24 12:30

    Error message are sent to stderr, so you have to redirect that as well to a file.

    Start your server with:

    ./server > err 2>&1
    
    点赞 评论 复制链接分享

相关推荐