简体   繁体   中英

How can I tell when another process has stopped writing to a file in Perl?

I have a system which is writing files to a folder using FTP. I need to copy those files, but only when they FTP system has finished. How do I tell when the first process has finished writing.

Another possibility is to have the process which uploads the files upload them under a temporary name and then rename them.

Renames happen atomically so there would be no case where the file was incomplete under its final name.

The copying process could ignore the temporary named files.

To extend zoul's idea: have a file that indicated the last time the target has been updated. After every upload, you touch that file.

A cron process on the other side can then periodically check for updates and do its job.

最简单的方法是创建一个指示已完成传输的文件?

You should use Linux::Inotify2 , it's made for that kind of thing ! :)

Just watch the 'IN_CLOSE' event on your FTP directory...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM