Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
11-04-2008, 09:05 AM
|
#1
|
Member
Registered: May 2003
Location: Oslo, Norway
Distribution: Ubuntu, Red Hat Enterprise Linux
Posts: 657
Rep:
|
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
|
|
|
11-04-2008, 06:02 PM
|
#2
|
Senior Member
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141
Rep: 
|
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"
|
|
|
11-05-2008, 03:16 AM
|
#3
|
Member
Registered: May 2003
Location: Oslo, Norway
Distribution: Ubuntu, Red Hat Enterprise Linux
Posts: 657
Original Poster
Rep:
|
Quote:
Originally Posted by gilead
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?
|
|
|
11-06-2008, 04:19 AM
|
#4
|
Member
Registered: May 2003
Location: Oslo, Norway
Distribution: Ubuntu, Red Hat Enterprise Linux
Posts: 657
Original Poster
Rep:
|
Quote:
Originally Posted by kenneho
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.
|
|
|
06-22-2009, 05:57 AM
|
#5
|
Member
Registered: Jun 2009
Location: INDIA
Distribution: RHEL-5
Posts: 174
Rep:
|
Quote:
Originally Posted by kenneho
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
}
|
|
|
03-23-2010, 01:13 PM
|
#6
|
LQ Newbie
Registered: Mar 2010
Posts: 9
Rep:
|
lol wron topic [edited]
Last edited by nanda_martins; 03-23-2010 at 01:14 PM.
|
|
|
All times are GMT -5. The time now is 04:21 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|