我想将时间戳和文件列表添加到日志中。目前,我只能得到一个。以下命令可以跟踪更新的文件列表,但不会添加时间戳。
rsync -avz --progress --delete /web/path/public_html/ $newhost:/web/path/public_html >> /var/log/rsync.log
sent 2345743 bytes received 43205 bytes 530877.33 bytes/sec
total size is 14828110173 speedup is 6206.96
sending incremental file list
error_log 5740980 100% 36.98MB/s 0:00:00 (xfer#1, to-check=1405/1524)
sent 2344322 bytes received 51694 bytes 684576.00 bytes/sec
total size is 14828115593 speedup is 6188.65
Run Code Online (Sandbox Code Playgroud)
下面的命令可以向日志添加时间戳,但它不会告诉哪些文件被更新。
rsync -avz --progress --delete /web/path/public_html/ $newhost:/web/path/public_html --log-file=/var/log/rsync1.log --log-file-format="%t \n"
2012/01/03 17:30:05 [10505] Total transferred file size: 6170062 bytes
2012/01/03 17:30:05 [10505] Literal data: 5470 bytes
2012/01/03 17:30:05 [10505] Matched data: 6164592 bytes
2012/01/03 17:30:05 [10505] File list size: 2333282
2012/01/03 17:30:05 [10505] File list generation time: 0.002 seconds
2012/01/03 17:30:05 [10505] File list transfer time: 0.000 seconds
2012/01/03 17:30:05 [10505] Total bytes sent: 2345435
2012/01/03 17:30:05 [10505] Total bytes received: 28628
2012/01/03 17:30:05 [10505] sent 2345435 bytes received 28628 bytes 527569.56 bytes/sec
2012/01/03 17:30:05 [10505] total size is 14828121798 speedup is 6245.88
Run Code Online (Sandbox Code Playgroud)
gue*_*tli 11
如果要查看 rsync 客户端上每个文件的时间,则需要使用 --out-format:
rsync -avz --out-format="%t %f %b" remotehost:tmp .
Run Code Online (Sandbox Code Playgroud)
输出如下所示:
2013/01/11 10:57:41 tmp/foo.txt 210
Run Code Online (Sandbox Code Playgroud)
日志格式字符串:
%t: time
%f: file
%b: transfered bytes
Run Code Online (Sandbox Code Playgroud)
来自 rsyncd.conf(5):
“默认的日志格式是“%o %h [%a] %m (%u) %f %l”,使用时总是以“%t [%p]”为前缀“日志文件”参数。”
2012/01/04 03:19:12 [1461] building file list
2012/01/04 03:19:12 [1461] .d..t...... ./
2012/01/04 03:19:14 [1461] >f+++++++++ file1.pdf
2012/01/04 03:19:14 [1461] >f+++++++++ file2.pdf
2012/01/04 03:19:14 [1461] >f+++++++++ file3.pdf
2012/01/04 03:19:14 [1461] sent 40892313 bytes received 72 bytes 16356954.00 bytes/sec
2012/01/04 03:19:14 [1461] total size is 81997177 speedup is 2.01
Run Code Online (Sandbox Code Playgroud)
我相信这就是你想要的吗?尝试不带 --log-format 选项的命令,阅读 rsyncd.conf 的手册页并搜索“日志格式”以查看自定义日志文件的选项。
我在 rsync 脚本中经常使用的另一个选项是在 rsync 之前/之后添加日期,例如:
date >> /var/log/rsync.log
rsync -avz --progress --delete /src /dst >> /var/log/rsync.log
date >> /var/log/rsync.log
Run Code Online (Sandbox Code Playgroud)
第三个也是最后一个选项是将您的 rsync 命令放在 bash 循环中,以在每一行前面加上日期。
归档时间: |
|
查看次数: |
32814 次 |
最近记录: |