linux centos7 命令中的 2>&1 代表的意义


2021-08-25

sh monitor.sh >> monitor.log 2>&1


0 – stdin (standard input) 标准输入
1 – stdout (standard output) 标准输出
2 – stderr (standard error) 标准错误输出

2>&1 就是将标准错误(2)重定向到标准输出(&1),标准输出(&1)再被重定向输入到 monitor.log 中,即只输出错误报告。