I have a server that when the contents of a specific folder are modified it will calculate a checksum.
The problem is that the calculation of the checksum takes about 30 minutes since it is recalculating every single file in that folder even if a simple text file has been modified. So while the checksum is running the files are not to be used.
The calculation of the checksum is done with the following command.
find . -type f | xargs md5sum > some_file
Every day new files are added to the folder and others are deleted.
Is there a way to update the checksum file only on the modified/added/deleted files without calculating the md5 for the rest of the files?
Edit: Clarification
The checksum needs to contain an md5 for every single file in that folder. What I am trying to achieve is a way to edit/update the checksum file when something changes in the folder:
- Remove md5 for file when deleted
- Add md5 for file when added in folder
- Update hash code when file is modified
All these without recalculating the entire folder from the top