Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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...

<?php
//download.php
//content type
header('Content-type: application/zip');
header('Content-Length: 46380748');
//open/save dialog box
header('Content-Disposition: attachment; filename="file.zip"');
//read from server and write to buffer
readfile('file.zip');
?>

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....

Thanks.

share|improve this question
add comment

2 Answers

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
add comment

Your Answer

 
discard

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.