When we do a
find in linux, I am guessing the kernel will store the result into buffer/cache. Let say after an hour, some changes of the folder and files happened, so my question is, when we do the next
i) Will the kernel get the wrong old result stored in buffer/cache ?
ii) How does kernel know there already some changes of the folder and files and it can't use back the result from the buffer/cache ? Is it doing a comparison between the new result and old result ? Wouldn't this even take up more time ? If not, how the kernel achieve such intelligent choice ?
iii) Do we ever need to worry about dropping the cache (i.e. :
echo 3 > /proc/sys/vm/drop_caches) to get the latest result of our operation let say
find ? or there are some scenario where we need to do such thing ? (although I feel we shouldn't need to, but just want to make sure)
iv) Let say there is a scenario where some cron script run a command (may be
grep a very huge file) that causing to taken up most of the resource of the server. We kill that process and truncate that huge file. That cron job then run again after few minutes. Do we need to drop the buffer/cache in order to avoid the next
grep getting the huge file content result stored in it to avoid it hang the server again ? (sorry if this question sound too silly to you)