I have a several GB directory that is rarely accessed, but when it is I'd like to be able to read the files in it quickly instead of having to wait. Since the files are rarely accessed they will not be in the file system cache, but I'd like to suggest that Linux preloads them in the file system cache before I go to access them.
Some may argue that I will need to wait for it to load them the first time and so I'm not saving any time -- suffice it to say that in my particular use case I can automate this so it is not a matter of saving system time, it is a matter of saving a user's time (as they don't need to wait if the files are cached).
I also realize that the file system cache is not a guarantee without using something like tmpfs, it is a suggestion to the OS, and I'm fine with this.
So it seems like the obvious method would be to do:
tar -cf - /mydirectory > /dev/null
However when I do this, the command returns immediately, even for a several GB directory. It appears that bash is seeing that the output is being directed to /dev/null and optimizing the entire command away, so tar is not actually even reading from the directory.
What is a simple command to make the OS read all the files in a directory?