LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-10-2010, 11:13 AM   #1
manouche
LQ Newbie
 
Registered: Apr 2008
Posts: 5

Rep: Reputation: 0
Logrotate question


Hello,

I am having a problem making my apache logs rotate at the specified time. I want them to rotate on the first of each month and to keep 6 months of logs. However, they seem to be rotating in a somewhat random fashion, for instance, July 19, June 14, May 26, April 7, March 15.

I have an 'httpd' entry in the /etc/logrotate.d directory. It looks like this:

/usr/local/apache2/logs/*log {
monthly
missingok
rotate 6
notifempty
create 640 root root
sharedscripts
postrotate
/usr/bin/killall -HUP httpd
endscript
}

Logrotate is in the /etc/cron.monthly directory.

My cron log for Aug 1 shows that cron.monthly ran successfully.

Can someone help me figure out what is going on? Thanks.
 
Old 08-10-2010, 02:17 PM   #2
SciFi-Bob
Member
 
Registered: Aug 2008
Location: Denmark
Distribution: Ubuntu
Posts: 62

Rep: Reputation: 18
If you are running an apache2 server, you should have a file like

/etc/logrotate.d/apache2

If not, it may be a bug in logrotate..
 
Old 08-10-2010, 02:33 PM   #3
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
Your problem description sounds like logrorate is rotating files at some default file size, regardless of your preference for monthly rotation.

Try decompressing a few of the files rotated at odd times. Are they all approximately the same size? If so, that is the default (I've not been able to find anything via google regarding such a default).

Then add a line to your logrotate config file: size=XXXk, or XXXm (where XXX is the file size to rotate). If the file rotates at mid month, double the value of the size= parameter which will hopefully rotate the file at month end. Of course, you must realize that the file will not necessarily always grow at the same rate, so there will be some variation on the rotation period.

An optional configuration would be to set the file size much larger than you expect it to be at month end, and use the -f option of logrotate to force log rotation at month end.
 
Old 08-10-2010, 02:41 PM   #4
manouche
LQ Newbie
 
Registered: Apr 2008
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks for your reply. The files are not being compressed. Here are file sizes of the log files. It doesn't appear to be rotating based on a specific size.

640260 access_log.3
497184 access_log.6
471304 access_log.1
355600 access_log.5
317008 access_log
304196 access_log.4
232016 access_log.2
 
Old 08-14-2010, 07:43 PM   #5
SciFi-Bob
Member
 
Registered: Aug 2008
Location: Denmark
Distribution: Ubuntu
Posts: 62

Rep: Reputation: 18
One difference I can see from my setup, is the first line in the file:

/usr/local/apache2/logs/*log {

On my server, it is:

/var/log/apache2/*.log {

(note the dot after the * wildcard)

It should not be significant, the shell should resolve the correct filename, but it would not be the first time such a thing is making a difference..

Just a thought..
 
  


Reply



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 question cytchiu Linux - Enterprise 2 06-03-2009 07:54 AM
Question about logrotate h725 Linux - Server 5 03-17-2009 03:01 AM
logrotate question sunman Slackware 3 02-21-2006 01:40 PM
a question about logrotate? hueofwind Linux - Newbie 3 11-08-2005 08:08 PM
A question on logrotate marcoc Linux - Networking 2 02-21-2003 05:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:51 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