Amir Tahvildaran on 25 Mar 2014 11:16:45 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] check for a file being transmitted via ftp


I have a different approach to FTP operations, but these guys have some good tips:
http://stackoverflow.com/questions/7241978/how-to-determine-wheter-a-file-is-still-being-transferred-via-ftp

briefly: try to get a lock on the file seems like the most straightforward

My approach would be to sub out the filesystem for FTP operations when processing is involved.  Use an FTP server library (nodejs or your favorite language) that handles events as they happen as opposed to polling.  If you're using FTP for more than just uploading to be processed, than nevermind.

-Amir


On Tue, Mar 25, 2014 at 2:05 PM, Eric at Lucii.org <eric@lucii.org> wrote:
I expect a file to be routinely transmitted to me via ftp.  A bash script,
invoked as a cron job, will process and then archive that ftp file.

All of that is easy/routine.

My question is: how do I know that the file is complete?  I don't want to
start processing the file without being sure that the ftp process is done.

I thought about checking the size of the file in bytes and then comparing that
to it's size 1 minute earlier... if it's not growing then it's probably done.
But, that's just *probably* as ftp could be stalled temporarily or worse.

I have also considered about using inotify cron (incron) but I expect that it
would be triggered at the file's creation - not when it's time for me to
process it.

Thanks
Eric
--
#  Eric Lucas
#
#                "Oh, I have slipped the surly bond of earth
#                 And danced the skies on laughter-silvered wings...
#                                        -- John Gillespie Magee Jr
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug


___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug