ole*_*ner 9 python linux rsync
我正在python中开发一个可以从多台机器上收集日志的脚本.我正在使用rsync.但是有一个问题.我有多个服务的日志,如下所示:
service1.log
service2.log
service3.log
... and so on
Run Code Online (Sandbox Code Playgroud)
此文件和文件夹的路径在代码中指定.但有时候,当某些日志文件不存在时,我会陷入困境.rsync没有成功完成.
如何跳过源计算机上不存在的文件?
PS我正在使用saltstack来统治机器,所以我打电话给:
__salt__['cmd.retcode']('rsync -a file1 file2...')
Run Code Online (Sandbox Code Playgroud)
unu*_*tbu 18
用途--ignore-missing-args:
版本3.1.0手册页说,
- 忽略失踪ARGS
Run Code Online (Sandbox Code Playgroud)When rsync is first processing the explicitly requested source files (e.g. command-line arguments or --files-from entries), it is normally an error if the file cannot be found. This option suppresses that error, and does not try to transfer the file. This does not affect subsequent vanished-file errors if a file was initially found to be present and later is no longer there.
例如:
% rsync --version
rsync version 3.1.0 protocol version 31
% rsync bogusfile dest
rsync: link_stat "/tmp/bogusfile" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1183) [sender=3.1.0]
% rsync --ignore-missing-args bogusfile dest
# <no error>
Run Code Online (Sandbox Code Playgroud)
该--ignore-missing-args选项加入3.06版本和3.1.0之间的一段时间.
该网络版3.06 rsync手册页并没有提到它.但是git存储库表明这个选项是在2009年添加的.