linuxbashiperfiperf3

run iperf in background and redirect output to a file


I am trying to start iperf server in background and redirect the output to a file. But it is not working.

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?


Solution

  • Instead of using the daemon option, use 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:

    $ [1] 1234
    

    You can stop it later by sending a SIGTERM using kill:

    $ kill -SIGTERM 1234