- 论坛徽章:
- 0
|
目的:想把watch每次的输出都重定向到同一个文件,用于最后的统计分析
比如说 watch -n 1 ifconfig eth0 这个命令,我试了 > , >> , tee ,但是都不能把每次的结果保存在文件中。
watch -n 1 ifconfig eth0 > /tmp/0123456.txt; 文件里面什么都没有
watch -n 1 ifconfig eth0 >> /tmp/0123456.txt; 文件里面什么都没有
watch -n 1 ifconfig eth0 | tee /tmp/0123456.txt; 输出只能保存最后一次结果,如下所示:
Every 1.0s: ifconfig eth0 Tue Sep 23 06:34:41 2014
Every 1.0s: ifconfig eth0 Tue Sep 23 06:34:41 2014
Every 1.0s: ifconfig eth0 Tue Sep 23 06:34:41 2014
eth0 Link encap:Ethernet HWaddr 00:50:56:B5:11:92
inet addr:10.91.117.25 Bcast:10.91.127.255 Mask:255.255.240.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:52982927 errors:0 dropped:0 overruns:0 frame:0
TX packets:40737873 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7536732506 (7.0 GiB) TX bytes:6816789784 (6.3 GiB) |
|