Is there a way to get a summary of how much bandwidth a given process used on Linux after the process completes? I do not want a monitor, I want something I can look at after the task has completed..

Ideally something like the "time" command or a profiler, but for network usage.

4 Answers 4


You could use http://nethogs.sourceforge.net/

You might also want to look through the answers given at https://serverfault.com/questions/44492/ip-process-based-bandwidth-usage-stats-tool-for-linux


It is possible to count packets in and out using iptables based on a PID, I understand that knowing the PID before a process is starting is next to impossible. Depending on your situation this maybe reliant.

iptables -A OUTPUT -p TCP -m owner --pid-owner $PID -j ACCEPT

You can check if the rule is being hit and how many packets have hit it, with the following command.

iptables-save -c

tcptrace is quite powerful and is probably able to do the things you want. Maybe it's a bit too low-level though...


Invoke the process from a script that awaits user input after completing the main process. This way, it doesn't terminate and you can use ntop or nethogs to see how much it downloaded/uploaded.

  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Oct 7, 2023 at 8:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .