1. 程式人生 > >shell exec命令執行shell打印輸出到一個文件

shell exec命令執行shell打印輸出到一個文件

code 文件 man IV bash AS KS 命令執行 In

[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

shell exec命令執行shell打印輸出到一個文件