How to determine if a file is in use

Christopher K. Johnson ckjohnson at gwi.net
Tue Nov 3 22:13:56 UTC 2009


Donald Russell wrote:
> Another system uses FTP to drop files in a directory for me to process.
> I have a bash script to process the incoming files. The script is 
> started by cron periodically.
>
> There's a problem if the FTP transfer is still in progress because the 
> process begins reading the file even though it isn't complete yet.
Do you have control of the FTP procedure that drops the files?  If so, 
transfer the files with one filename, and when complete, use ftp to 
rename the file.  The rename is atomic.  e.g.:
put foo.bar foo.bar.xfer
rename foo.bar.xfer foo.bar

Then have the cron job only process files without the .xfer appended to 
name.

Chris




More information about the fedora-list mailing list