在`nohup`进程后台运行`mtr`网络诊断工具
问题描述:
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
时,无法注销服务器。
我需要mtr
至output to a textfile
和run in background
类似于nohup
命令。
我也应该能够看看报告,就像在输出文件上使用tail -f
一样。
答
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
对输出文件。