shell exec命令执行shell打印输出到一个文件
[root@master ~]# cat 1.sh #!/bin/bash exec 1>> /tmp/2.log 2>>/tmp/2.log date echo 111 ldkkdfkslfds date [root@master ~]# ./1.sh [root@master ~]# cat /tmp/2.log Sat Jun 9 15:08:19 UTC 2018 111 ./1.sh: line 6: ldkkdfkslfds: command not found Sat Jun 9 15:08:19 UTC 2018 Sat Jun 9 15:10:39 UTC 2018 111 ./1.sh: line 6: ldkkdfkslfds: command not found Sat Jun 9 15:10:39 UTC 2018