How can I tell when an FTP is complete?

Posted by identry on Super User See other posts from Super User or by identry
Published on 2010-05-28T19:53:18Z Indexed on 2010/05/28 20:04 UTC
Read the original article Hit count: 131

Filed under:
|

I have a cron job that processes files that my client's upload via FTP to my FreeBSD server. The cron job runs once an hour, and normally processing each file only takes a few seconds.

The cron job looks in the client's upload directory and moves any new files to a tmp directory. It then processes the file(s) and moves them into a final directory where they are then available to the public through a website.

The problem is, every once in awhile, the cron job runs just as a new file is being uploaded. It moves the half-uploaded file to the tmp directory, and tries to process it, and fails, of course.

Question: how can I determine if the uploaded file is complete? The only thing I can think of is checking the file size to see if it's changing, but that seems like a kludge. Is there some sort of flag or something that is set when the upload is complete?

© Super User or respective owner

Related posts about unix

Related posts about shell-script