O'Reilly Hacks
oreilly.comO'Reilly NetworkSafari BookshelfConferences Sign In/My Account | View Cart   
Book List Learning Lab PDFs O'Reilly Gear Newsletters Press Room Jobs  


How to view the latest rotated apache log in linux.
A quick way to get the latest rotatelogs-generated logfile, and tail it.

Contributed by:
Unknown User anonymous2
[02/19/04 | Discuss (0) | Link to this hack]

Lets say your dataset is: httpd_error.123123123.log or, httpd_access.12123123123.log this will do the trick. tail -f `ls -1t httpd_error* | head -1` or tail -f `ls -1t httpd_access* | head -1` I *don't* think this requires GNU ls, but *BSD users could give it a whirl. All other options work on any unix that has the tail and head commands. IOW, pretty much anything. Have fun, and play around with it and look at the options. This is a great trick some of us who admin large sites use in a quick and dirty rush to get at the latest log, this second. Works for more than just apache logs, as well. Anything that is rotated and has a non-distinct logfile for the latest log, can use this.

O'Reilly Home | Privacy Policy

© 2007 O'Reilly Media, Inc.
Website: | Customer Service: | Book issues:

All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.