【发布时间】:2019-07-14 12:34:33
【问题描述】:
下面有一些示例代码,我使用 tar/dd 将文件备份到磁带...
time tar -cvf - \
/home/user1 \
/home/user2 | dd bs=128k of=/dev/rmt0 2>&1 | tee -a debug.log
mail -s "testing" admin@domain.com < debug.log
问题是当我运行它时,以下内容会打印到屏幕上...
a /home/user1/fileA 10 blocks.
a /home/user2/fileB 1 blocks.
0+1 records in.
0+1 records out.
real 0m2.253s
user 0m0.003s
sys 0m0.002s
但只有以下内容被重定向到日志文件...
cat debug.log
0+1 records in.
0+1 records out.
有没有办法将所有输出重定向到日志?
我尝试在 tar/dd 管道之间添加 tee 命令,但没有奏效。
这是在运行 IBM AIX 的系统上,所以我无法访问那里的许多 GNU 工具。
【问题讨论】:
-
明确地说,您也想重定向
time输出吗?哪个特定 shell?这在 bash(其中time是内置的)和它的任何外部位置之间非常不同。 -
是的,时间也是如此,打印到屏幕上的所有内容。
-
-
...虽然我想有人可能还添加了How to redirect stderr to a file for the whole pipe 作为第二个副本并称之为完成。
-
我在发布前尝试了第一个链接,没有成功。也许我错过了什么,会重新访问。