Is it possible to calculate the last modified time of a directory, taking changing file contents into account?
We are trying to watch a series of upload directories to determine when user FTP sessions are complete.
Users are uploading a set of files into a specific directory, and we'd like to detect when the last file within that directory hasn't changed within N minutes. (We are using this as a proxy for "FTP session is done".)
We started with this to find directories that have been idle for more than 5, but less than 10, minutes:
find . -mmin +5 -mmin -10 -type d -ls
The directory timestamp used here is based on the time the most recent file was added to the directory.
I have read Directory last modified date and it is clear that reading the mtime or mmin for the directory won't work since it doesn't change when files within the directory have their contents updated. Thus, the above won't work because if that last file is a large file that may take > 10 minutes to upload then the directory won't really have been idle (i.e. all files unchanged) when this triggers.
Are there a shell-based alternatives (ideally a configuration of the find
command) that use the mtime of the last changed file inside as the timestamp, but still operate at the directory level (i.e. we don't want to get multiple hits based on all the files inside a single directory)?