bash 在后台运行 iperf 并将输出重定向到文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43462401/
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
run iperf in background and redirect output to a file
提问by
I am trying to start iperf server in background and redirect the output to a file. But it is not working.
我正在尝试在后台启动 iperf 服务器并将输出重定向到一个文件。但它不起作用。
server:
服务器:
iperf3 -s -D >> /tmp/listen.txt
or
iperf3 -s -D > listen.txt
client:
客户:
iperf3 -c <server-ip> -B <client-ip> > send.txt
I am able to see output in send.txt on client but on server, I don't see anything being written in any file. Can someone help me with this command?
我能够在客户端上的 send.txt 中看到输出,但在服务器上,我没有看到任何文件中写入的任何内容。有人可以帮我完成这个命令吗?
采纳答案by David Cullen
Instead of using the daemon option, use nohup
:
而不是使用守护程序选项,使用nohup
:
nohup iperf3 -s >> /tmp/listen.txt 2>&1 &
That will put iperf3 in the background and make it immune to hangups. The shell will print out the job number and PID:
这会将 iperf3 置于后台并使其不受挂断影响。shell 将打印出作业号和 PID:
$ [1] 1234
You can stop it later by getting sending a SIGTERM using kill
:
您可以稍后通过使用kill
以下方式发送 SIGTERM 来停止它:
$ kill -SIGTERM 1234
回答by Bruce A. Mah
On any recent iperf3:
在任何最近的 iperf3 上:
iperf3 --server --daemon --logfile iperf3.txt --pidfile iperf3.pid
(substitute short command line flags if you like)
(如果您愿意,可以替换短命令行标志)
The server output will go to the file iperf3.txt
. The process ID will be stored in the file iperf3.pid
...you can look that up when you want to kill the process.
服务器输出将转到文件iperf3.txt
。进程 ID 将存储在文件中iperf3.pid
……您可以在要终止进程时查看该文件。
If you want to be sure that output makes it to the file in a more timely manner (possibly at a very small hit to performance), add the --forceflush
flag.
如果您想确保输出以更及时的方式(可能对性能的影响很小),请添加该--forceflush
标志。