Wednesday, August 27, 2008

Tailf - watch the linux log file grows

Another overused linux command that has been quite around from this linux blog entry and widely used command on monitoring log file tail. Tail binary allows a user to watche the growth of a log file. Watching the log file grows can be done using an additional -f parameter. Alternatively, another approach to watch a log file grows can be done using tailf binary command.

To tailf or to tail -f ? That is the question.

Tailf binary is part of util-linux-ng linux package while tail binary is part of coreutils linux package.

File size difference of tailf and tail binary command:

# ls -la /usr/bin/tailf /usr/bin/tail

-rwxr-xr-x 1 root root 7416 2007-10-16 21:48 /usr/bin/tailf
-rwxr-xr-x 1 root root 43576 2007-10-30 17:52 /usr/bin/tail

Man Tailf
Tailf will print out the last 10 lines of a file and then wait for the file to grow. It is similar to tail -f but does not access the file when it is not growing. This has the side effect of not updating the access time for the file, so a filesystem flush does not occur periodically when no log activity is happening. Tailf requires only a single parameter when watching a growing log file. Tailf follows the following command format

# tailf logfile

Tailf is extremely useful for monitoring log files on a laptop when logging is infrequent and the user desires that the hard disk spin down to conserve battery life.

Tailf Usage Examples

# tailf /var/log/messages
# tailf /var/log/maillog


HTH

0 comments:

Sign up for PayPal and start accepting credit card payments instantly.
ILoveTux - howtos and news | About | Contact | TOS | Policy