Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to look through my apache access log backwards. How can I do that on Ubuntu?

share|improve this question
up vote 8 down vote accepted

print the file from the last line to the first one (the older the line is the more it will be printed close to the end):

tac /my/file | less
share|improve this answer

have you tried the command "tac"? It cats files backwards.

share|improve this answer

First You may configure your /etc/logrotate.conf, man logrotate for more information. You can specify some infomations : If you want to rotate log files weekly and keep 4 weeks worth of backlogs

rotate 4

After you can browse you log 4 weeks ago, using you favorite viewer, like awstat, tail -f ...

share|improve this answer
interesting...what if i have 8 websites on one server ...that's 8 access logs? – Tony Sep 9 '09 at 14:14
The rotation is made for all /etc/logrotate.d file. and by default for all /var/log/apache2/*.log – mezgani Sep 9 '09 at 15:45
Whether or not your 8 websites create separate log files depends on the configuration of each site. If you use apache, you should/could have an individual vhost config file per site where you can define the logfiles. – wolfgangsz Sep 9 '09 at 16:35

Go to the end of the file and press the up arrow?

share|improve this answer

If a rotation is made, look into the configuration of the rotation. If a rotation is made every 4 days, that means that you will have to look on the archive made 4 days ago in order to read the period of time log.

You will find in the log directory tar.gz files (which are archives of the log) like samba.1.tar.gz, samba.2.tar.gz simply extract the file you want

tar -zxvf samba.2.tar.gz

and you will be able to read old logs.

share|improve this answer

do you mean tail the logfile? use tail -f to monitor the logfile.

share|improve this answer
no, i mean navigate the file backwards – Tony Sep 9 '09 at 14:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.