Exclude incomplete files in ls -rlt

Hi All,

I am bit puzzled with this requirement where I need to list the files in a directory. However, files are being continuously written to this folder through FTP. Hence I need to exclude the file which is being written at the time of listing the directory. I thought of using file time stamp. I can list files with timestamps 5 minutes before the time I run ls -lrt command. I believe time taken to ftp the file will not take more than 5 minutes based on my observation.
I am not sure how do I list file based on time. Any help on this is highly appreciated. If there is any other option, please let me know.

Thanks
Angshuman

If your system supports it, you can use find <dir> -mmin -5

Hi Subbeh,

Thank you for your reply. I am using HPUNIX and it does not support mmin.

Thanks
Angshuman

---------- Post updated at 04:21 PM ---------- Previous update was at 01:23 PM ----------

Hi All,

Is there any other way to achieve this as the suggestion provided by Subbeh does not work for me.

Thanks
Angshuman

You could try to identify open files by using lsof on that directory, and then exclude those.

Or fuser .

Could I suggest a simple reference file:-

touch my-ref-file
sleep 5
find dir ! -newer my-ref-file 

The sleep is just to ensure that at least some further file growth from an incoming FTP will occur. Slower than that, then I would expect the FTP to timeout anyway.

I hope that this helps,
Robin
Liverpool/Blackburn
UK