2017-01-19 150 views
-1

mtr是调试网络丢包的好工具。这里我抽样mtr输出。 My traceroute [v0.85] myserver.com (0.0.0.0) Thu Jan 19 04:10:04 2017 Resolver: Received error response 2. (server failure)er of fields quit Packets Pings Host Loss% Snt Last Avg Best Wrst StDev 1. 192.168.104.23 0.0% 11 0.6 0.6 0.5 0.8 0.0 2. machine1.com 0.0% 11 8.5 12.4 2.0 20.5 5.5 3. mchine2.org.com 0.0% 11 1.2 1.0 0.8 1.8 0.0 4. machine3.orgcom 0.0% 11 0.8 0.9 0.7 1.1 0.0 在`nohup`进程后台运行`mtr`网络诊断工具

但是,在服务器上运行mtr时,无法注销服务器。

我需要mtroutput to a textfilerun in background类似于nohup命令。

我也应该能够看看报告,就像在输出文件上使用tail -f一样。

回答

0

mtr优惠-r选项,将mtr置入报告模式。在此模式下,mtr将运行-c选项指定的周期数,然后打印统计数据并退出。所以我们可以创建一个脚本来运行命令并将脚本放到日程表中的cron条目上。例如:

/usr/sbin/mtr -r -c 2 www.google.com >> /home/mtr.log 

cron项,每分钟运行:

* * * * * sh /path/to/script 

然后你可以tail -f对输出文件。