bash rsync 在哪里保存完整和不完整数据传输的日志文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13057454/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Where does rsync keep the log file for complete and incomplete data transfers?
提问by user1709815
I want to get the IPs of all the destination devices where my data transfer using rsync
could not be complete (or even start) as those devices are not connected to Internet or got disconnected while data transfer ...
我想获取我的数据传输使用rsync
无法完成(甚至无法启动)的所有目标设备的 IP,因为这些设备未连接到 Internet 或在数据传输时断开连接...
My actual problem scenario is :
我的实际问题场景是:
rsync -t Desktop/sony.pdf [email protected]: ssh: connect to host a.b.c.d port 22: No route to host
rsync -t Desktop/sony.pdf home@abcd: ssh: 连接到主机 abcd 端口 22: 没有到主机的路由
and I want the list of all such IPs where the data transfer could not be complted ...
并且我想要无法完成数据传输的所有此类 IP 的列表...
the list of all IPs like 'a.b.c.d '
所有 IP 的列表,如“abcd”
采纳答案by F. Hauri
I do the job in perl (in command line):
我在 perl 中完成工作(在命令行中):
# perl -ne '
($conn{}->{"ip"},$conn{}->{"started"})=(,) if
/^(.{15}).*rsyncd\[(\d+)\]:\sconnect.*\((\d+\.\d+\.\d+\.\d+)\)/;
$conn{}->{"closed"}= if /(.{15}).*rsyncd\[(\d+)\]:\ssent\s.*\stotal/;
END {
print "Good:\n";
map{
printf "%s %-16s %s\n",
$conn{$_}->{"started"},$conn{$_}->{"ip"},$conn{$_}->{"closed"} if
$conn{$_}->{"closed"};
} sort { $conn{$a}->{"started"} cmp $conn{$b}->{"started"}
} keys %conn;
print "Unterminated:\n";
map{
printf "%s %s\n",$conn{$_}->{"started"},$conn{$_}->{"ip"};
} sort { $conn{$a}->{"started"} cmp $conn{$b}->{"started"}
} grep { ! defined $conn{$_}->{"closed"}
} keys %conn;
}' < /var/log/daemon.log
This could produce outputs like:
这可能会产生如下输出:
Good:
Apr 28 08:12:01 127.0.0.1 Apr 28 08:15:35
Apr 28 08:27:01 192.168.1.36 Apr 28 08:28:04
Apr 28 08:42:01 127.0.0.1 Apr 28 08:42:13
Apr 28 08:57:01 192.168.1.36 Apr 28 08:57:16
Apr 28 09:12:01 127.0.0.1 Apr 28 09:12:28
Apr 28 09:27:01 192.168.1.36 Apr 28 09:27:13
Apr 28 09:42:01 127.0.0.1 Apr 28 09:42:09
Apr 28 09:57:02 192.168.1.36 Apr 28 09:57:16
Apr 28 10:12:01 127.0.0.1 Apr 28 10:12:32
Apr 28 10:27:01 192.168.1.36 Apr 28 10:27:12
Apr 28 10:42:01 127.0.0.1 Apr 28 10:42:14
Apr 28 10:57:01 192.168.1.36 Apr 28 10:57:13
Apr 28 11:27:01 192.168.1.36 Apr 28 11:28:01
Apr 28 11:42:01 127.0.0.1 Apr 28 11:44:32
Apr 28 11:57:02 192.168.1.36 Apr 28 11:58:43
Apr 28 12:12:01 127.0.0.1 Apr 28 12:12:27
Apr 28 12:27:01 192.168.1.36 Apr 28 12:28:48
Apr 28 12:42:01 127.0.0.1 Apr 28 12:42:13
Apr 28 12:57:01 192.168.1.36 Apr 28 12:57:56
Unterminated:
Apr 28 11:12:01 127.0.0.1
回答by kbulgrien
You can say where the log file is (per the man page documentation):
您可以说出日志文件的位置(根据手册页文档):
--log-file=FILE override the "log file" setting
回答by F. Hauri
Logs infos are normaly sent via syslog daemon, when rsync run in daemon mode.
当 rsync 在守护进程模式下运行时,日志信息通常通过 syslog 守护进程发送。
If you want to log someting when using rsync over ssh, you have to put option in command line:
如果要在通过 ssh 使用 rsync 时记录某些内容,则必须在命令行中添加选项:
rsync --rsync-path='/usr/bin/rsync --log-file=$HOME/.rsyncd.log' -t Desktop/sony.pdf [email protected]:
for saving logs in destination host or
用于在目标主机中保存日志或
rsync --log-file=$HOME/.rsyncd.log -t Desktop/sony.pdf [email protected]:
for saving logs in source host.
用于在源主机中保存日志。
回答by kbulgrien
Search for evidence of rsync in the system logs. For example:
在系统日志中搜索 rsync 的证据。例如:
sudo grep -ir rsync /var/log
For that matter, you could grep / though that is overkill.
就此而言,您可以 grep / 虽然这有点矫枉过正。