我想将时间戳和文件列表添加到日志中。 目前,我只能得到一个。 以下命令可以跟踪更新的文件列表,但不会添加时间戳。
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
以下命令可以将时间戳记添加到日志中,但不会告知哪些文件已更新。
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
从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
我相信这是你想要的? 尝试不带-log-format选项的命令,阅读rsyncd.conf的手册页并search“日志格式”以查看您必须自定义日志文件的选项。
我经常在rsync脚本中使用的另一个选项是在rsync之前/之后添加date,如:
date >> /var/log/rsync.log rsync -avz --progress --delete /src /dst >> /var/log/rsync.log date >> /var/log/rsync.log
第三个也是最后一个选项是把你的rsync命令放在一个bash循环中,以每行的前面加上date。
如果您想要查看rsync客户机上每个文件的时间,则需要使用–out-format:
rsync -avz --out-format="%t %f %b" remotehost:tmp .
输出如下所示:
2013/01/11 10:57:41 tmp/foo.txt 210
日志格式string:
%t: time %f: file %b: transfered bytes
replace>> /var/log/rsync.log replace为--log-file=/var/log/rsync.log -q