Q: Fetching all PHP files and store their size I like to monitor every php file with their size (and if a new file has been added).
On my server are more than 200 000 of em so find takes very long.
This is what I do:
ls -1 --size $(find -P . -type f -name "*.php")

This takes hours.
Is there anything I can do to make this monitoring faster? (Except a faster Server)
Or is there any trick that give a file list with file size or crc32 ?
In addition I do not know if this would be faster:
find . -P -type f -name "*.php" -exec ls -1 --size \{} \;


A: The find command has a -printf option that can be used to print the size of the file without having to exec ls 
find . -name '*.php' -printf "%p %s\n" 

You can use the sha512sum (or md5sum) to take a list of files and produce hashes for them which can later be used to check their integrity
find . -name '*.php' | while read line; do sha512sum "$line"; done

If you capture the output of the command above to a file you can then use sha512sum to check their integrity
sha512sum -c file


A: Use OSSEC for integrity check.
