Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Newbie sys-admin here,

On my website, users download a 50MB file. I want to be able to know whether the download has completed for them so that I can run a bash script. I'm on a LAMP stack, and the php code to send the file is like this...

//content type
header('Content-type: application/zip');
header('Content-Length: 46380748');
//open/save dialog box
header('Content-Disposition: attachment; filename=""');
//read from server and write to buffer

I've tried netstat, but couldn't seem to get anywhere. I saw the tcp connection but couldn't compute figure out how to track the total bytes sent to compare it with the file size. I've read that tshark might do the trick, but that seems like overkill. Am I missing something basic? Is this something I can monitor with apache? I'm stumped....


share|improve this question

I think you're on the wrong track here, adding up bytes on interfaces is not going to be an effective way to know if a user has downloaded a particular file. Even if you get it to work, you will always be hampered by the fact that it is a brittle hack.

You should look into some other kind of session tracking to know what your users are up to.

share|improve this answer

Check out jnettop or iftop.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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