Script day: output the tail of a log based on time
As system administrators we often want to list the last few lines from a log file in order to track problems and see system reports. The UNIX command tail
is very useful for that purpose and lets you display an arbitrary number of lines from the bottom of any file.
But often this is not really what you want – an administrator might want to see what happens in the last X minutes and the common practice to do this is to run tail with a guessed number of lines, see if you get what you want and if its not enough increase the number and try again.
Here’s another approach that works well if the log file you want to trace has time stamps for its lines (more…)