0

I'm using iperf3 in Ubuntu 20.

When not writing to a log file, iperf3 can provide a report every second with the -i 1 option. Using the --logfile option redirects all output to the file and inhibits any terminal output.

One way to get both terminal and file output is to use tee:

NOW=$( date '+%F_%H-%M-%S' )
iperf3 -c 192.168.50.1 -p 5201 -R  -i 1 -T 1str-$NOW | tee  iperf-1str-log-$NOW.txt

In this case, iperf runs for 10 seconds and provides no output to the terminal. When the 10 second execution is complete, all 10 lines of output appear on the terminal at once.

How can I "flush" tee to the terminal after every line of input?

Or is there a different way to accomplish this?

tim11g
  • 1,935
  • 5
  • 27
  • 41
  • This isn't `tee`'s choice; it's always unbuffered. – Charles Duffy Mar 06 '21 at 21:20
  • More likely `iperf` buffers stdout when it's not going to a TTY (which happens to be default libc behavior). See `stdbuf` to turn that off. I'm sure we have duplicates already in the knowledge base. – Charles Duffy Mar 06 '21 at 21:20
  • 1
    https://stackoverflow.com/questions/11337041/force-line-buffering-of-stdout-when-piping-to-tee – Mark H Mar 06 '21 at 21:20

0 Answers0