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?

  • Have you tried iperf -s -D > iperflog?
    – novice
    Jan 12 '19 at 19:35
  • I'm running that command exactly.
    – Jacktose
    Jan 13 '19 at 20:23
  • 1
    Sorry, I meant iperf -s -D -o iperflog
    – novice
    Jan 15 '19 at 3:17

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.

  • 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.)
    – Jacktose
    Feb 3 '20 at 23:21
  • Thanks @novice & @NickDancer!
    – Jacktose
    Feb 3 '20 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. Feb 3 '20 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).
    – Jacktose
    Feb 5 '20 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.