On Jan 25, 2008 9:20 AM, <[EMAIL PROTECTED]> wrote: > How long of a sleep would be required to *KNOW* a change has happened > with something external writing to files?
You want to be sure the other task is finished? Several days of waiting should suffice for better than 99.999% of all cases. If you can tolerate a lower reliability rate (i.e., occasionally processing a file before it's ready), you can cut that delay by many orders of magnitude. There is, in general, no way to be sure that somebody writing a file doesn't still have some writing or post-processing yet to do. But there are partial solutions that work well in most practical cases. Sometimes the file format is one (like XML) that shows end-of-data on its own. Sometimes the program writing the file can be made to lock the file while writing it or to otherwise signal when it is finished. Sometimes the solution is to move finished files (atomically) into the monitored directory from a staging directory on the same mounted volume. Sometimes the solution is to put only symbolic links to finished files into the monitored directory. Sometimes the OS or other tools can tell you when the file has been written (but they can be fooled by, e.g., a shell script or makefile that writes a file in chunks). Sometimes it works to wait for a predetermined amount of time after some event, then to assume (i.e. hope) that the file is finished. That last is a common solution; if a tolerable time delay and maybe a little program logic can make errors reasonably infrequent, and if the circumstances make errors reasonably easy to recover from, it's not a bad solution. Good luck with it! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/