Redirect stderr and stdout in Bash

后端 未结 15 934
日久生厌
日久生厌 2020-11-22 08:18

I want to redirect both stdout and stderr of a process to a single file. How do I do that in Bash?

15条回答
  •  深忆病人
    2020-11-22 08:57

    LOG_FACILITY="local7.notice"
    LOG_TOPIC="my-prog-name"
    LOG_TOPIC_OUT="$LOG_TOPIC-out[$$]"
    LOG_TOPIC_ERR="$LOG_TOPIC-err[$$]"
    
    exec 3>&1 > >(tee -a /dev/fd/3 | logger -p "$LOG_FACILITY" -t "$LOG_TOPIC_OUT" )
    exec 2> >(logger -p "$LOG_FACILITY" -t "$LOG_TOPIC_ERR" )
    

    It is related: Writing stdOut & stderr to syslog.

    It almost work, but not from xinted ;(

提交回复
热议问题