2

According to documentation, iperf (v2) server can be run in daemon mode and send its output to a log file like this: iperf -s -D > iperflog

I'm running that command exactly, as a regular user, from my home directory on CentOS, but the log file is always empty.

If I run it without -D, it behaves as expected, creating a log file like this:

------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
[ 4] local x.x.x.x port 5001 connected with x.x.x.x port 50928
[ ID] Interval Transfer Bandwidth
[ 4] 0.0- 3.0 sec 100 MBytes 279 Mbits/sec

Is this a bug in iperf, or do I not understand output redirection, or what?

asked Nov 17, 2017 at 0:06
3
  • Have you tried iperf -s -D > iperflog? Commented Jan 12, 2019 at 19:35
  • I'm running that command exactly. Commented Jan 13, 2019 at 20:23
  • 1
    Sorry, I meant iperf -s -D -o iperflog Commented Jan 15, 2019 at 3:17

1 Answer 1

2

Was having this issue after trying the exact same thing. As novice mentions in the comments, there is an -o flag which should output to file, however I found this didn't work under linux despite being in the man page. Ultimately what I needed was for iperf to continue running after ssh session interruption. In the end I used the following command.

nohup iperf -s > iperflog 2>&1 &

To break that down a little, we're running iperf with the server flag and redirecting stdout to the file iperflog. 2>&1 is redirecting stderr to stdout to ensure all output is captured in this file, including errors. The & tells the shell to run this command in the background. This will still result in the process being terminated when the session closes as it will be sent a SIGHUP. nohup fixes this by ignoring that signal and allowing the process to continue running.

You can then run tail -f iperflog to view the output in the shell as it would normally appear.

This is not ideal as it does require a shell where as the previous command shouldn't, but this got me where I needed.

answered Feb 2, 2020 at 6:41
3
  • That creates no output file at all. (I noticed that in the doc, that's listed under "Win32", but it's also in the Linux man page.) Commented Feb 3, 2020 at 23:21
  • @Jacktose I jumped the gun on this one, sorry. Trusted it would work because it was documented but it didn't. Have updated the answer above with an alternate command that worked for my needs. Commented Feb 3, 2020 at 23:47
  • Thanks for your work figuring it out! A while ago I did basically that by running it in a screen. I wonder whether and how to submit a bug (or two). Commented Feb 5, 2020 at 17:33

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.