LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 11-04-2008, 09:05 AM   #1
kenneho
Member
 
Registered: May 2003
Location: Oslo, Norway
Distribution: Ubuntu, Red Hat Enterprise Linux
Posts: 657

Rep: Reputation: 40
Logrotate doesn't rotate logs


Hi.


I've configured logrotate to rotate two of the Apache log files weekly, but it doesn't seem to be working. This is my configuration:

Code:
/var/log/httpd/access_log /var/log/httpd/ssl_access_log { 
    missingok 
    weekly 
    rotate 156   # Keep logs for 3 years 
    compress 
    sharedscripts 
    postrotate 
        /sbin/service httpd reload > /dev/null 2>/dev/null || true 
    endscript 
}
I did this maybe a couple of week ago. The result is this:
Code:
[root@server httpd]# ll -h ssl_access_log* 
-rw-r--r-- 1 root root 3.3M Nov  4 14:53 ssl_access_log 
-rw-r--r-- 1 root root  22K Oct 17 12:48 ssl_access_log.1
As one can see these has been a lot more than a week since the last rotate. Can anyone see why logrotate doesn't rotate the logs?
And what's the best way to debug these kind of problems?

Regards,
kenneho
 
Old 11-04-2008, 06:02 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
I can't find the docs I had on why this was happening to me as well, but I ended up using Apache's log rotation commands instead of logrotate for my web logs. I have the following in httpd.conf on one of my boxes:
Code:
CustomLog "|/usr/local/apache2/bin/rotatelogs -l /var/log/httpd/access.log.%Y-%m-%d 2419200"
 
Old 11-05-2008, 03:16 AM   #3
kenneho
Member
 
Registered: May 2003
Location: Oslo, Norway
Distribution: Ubuntu, Red Hat Enterprise Linux
Posts: 657

Original Poster
Rep: Reputation: 40
Quote:
Originally Posted by gilead View Post
I can't find the docs I had on why this was happening to me as well, but I ended up using Apache's log rotation commands instead of logrotate for my web logs. I have the following in httpd.conf on one of my boxes:
Code:
CustomLog "|/usr/local/apache2/bin/rotatelogs -l /var/log/httpd/access.log.%Y-%m-%d 2419200"
I didn't know Apache came with it's own logrotate implementation. Nice feature. It's bugging me, though, that linux logrotate doesn't work, so if anyone knows what may be causing this I'd greatly appreciate a hint.

Anyways, I found Apache's logrotate script under /usr/sbin/rotatelogs, and this is the information I got from the script:

Code:
[root@server ~]# /usr/sbin/rotatelogs -h 
Usage: /usr/sbin/rotatelogs [-l] <logfile> <rotation time in seconds> [offset minutes from UTC] or <rotation size in megabytes>

Add this: 

TransferLog "|/usr/sbin/rotatelogs /some/where 86400" 

or 

TransferLog "|/usr/sbin/rotatelogs /some/where 5M" 

to httpd.conf. The generated name will be /some/where.nnnn where nnnn is the 
system time at which the log nominally starts (N.B. if using a rotation time, 
the time will always be a multiple of the rotation time, so you can synchronize 
cron scripts with it). At the end of each rotation time or when the file size 
is reached a new log is started.
I doesn't seem like there is any kind of file size compression going on. Is the only solution writing a cron job myself to handle this?
 
Old 11-06-2008, 04:19 AM   #4
kenneho
Member
 
Registered: May 2003
Location: Oslo, Norway
Distribution: Ubuntu, Red Hat Enterprise Linux
Posts: 657

Original Poster
Rep: Reputation: 40
Quote:
Originally Posted by kenneho View Post
Code:
/var/log/httpd/access_log /var/log/httpd/ssl_access_log { 
    missingok 
    weekly 
    rotate 156   # Keep logs for 3 years 
    compress 
    sharedscripts 
    postrotate 
        /sbin/service httpd reload > /dev/null 2>/dev/null || true 
    endscript 
}

This is quite embarrasing, but I suspect that the reason why the above code didn't work was because of the comment (i.e. "# Keep logs for 3 years"). I found this in the man page:
Code:
Note that comments may appear anywhere in the config file as long as the first non-whitespace character on the line is a #.
I have to wait a while to verifiy that I got logrotate working, but it seems very promising.
 
Old 06-22-2009, 05:57 AM   #5
vap16oct1984
Member
 
Registered: Jun 2009
Location: INDIA
Distribution: RHEL-5
Posts: 174
Blog Entries: 3

Rep: Reputation: 38
Cool

Quote:
Originally Posted by kenneho View Post
This is quite embarrasing, but I suspect that the reason why the above code didn't work was because of the comment (i.e. "# Keep logs for 3 years"). I found this in the man page:
Code:
Note that comments may appear anywhere in the config file as long as the first non-whitespace character on the line is a #.
I have to wait a while to verifiy that I got logrotate working, but it seems very promising.
hey i linux u can easily rotate logs..

pls use this it will work

"/var/log/httpd/access.log" /var/log/httpd/error.log {
rotate 5
mail www@my.org
size=100k
sharedscripts
postrotate
/sbin/killall -HUP httpd
endscript
}
 
Old 03-23-2010, 01:13 PM   #6
nanda_martins
LQ Newbie
 
Registered: Mar 2010
Posts: 9

Rep: Reputation: 0
lol wron topic [edited]

Last edited by nanda_martins; 03-23-2010 at 01:14 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Logrotate: Rotate Apache logs, but never delete kenneho Linux - Newbie 2 10-23-2008 07:58 AM
'logrotate' does not rotate news logfile andrew.46 Slackware 2 01-28-2008 04:43 PM
How to get logrotate to only rotate files 2 days old. yoda_mon Linux - Software 1 05-18-2006 09:55 PM
rotate apache logs curos Slackware 2 04-20-2006 04:29 AM
rotate apache logs Berhanie Slackware 5 12-15-2004 10:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 12:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration