On the T(r)ail of Open Files
Learn how Linux manages open files and explore a number of utilities to watch files as they grow.
Wednesday, December 15th, 2004
If you’re more of a Linux user than a programmer, you may not have given much thought to how the operating system handles files. As a user, you simply give a filename to a program (from the “Open” command on a menu, from the command line, or however) and the file is (hopefully) accessed however it’s supposed to be.
However, programmers who perform low-level access of files– for instance, to seek to a particular point in a file or rewinding the file to its start– have to understand more about Linux file handling. That’s where we’re headed this month: seeing how Linux handles files that have been opened by a program, and learning how you can take advantage of this even if you don’t usually write programs that handle files.
Along the way, we’ll look at tail –f, MultiTail, and less+F. These three programs can show you what’s happening to a file as it grows (as data is added to end of the file). They’re handy for viewing log files and monitoring a long-running process.
Open Files
Let’s start with a quote from the Linux man page for open(), the low-level system call that programmers can use to open a file: