Author Topic: Logrotate issue  (Read 1567 times)

Mop

  • Hero Member
  • *****
  • Posts: 836
  • I POST CP
    • View Profile
    • Homepage
Logrotate issue
« on: October 05, 2011, 04:26:39 PM »
Hi guys,

I am trying to set up Logrotate on my ubuntu server. I want it to rotate my apache logs when they reach over 100Mb in size. However, it seems to be rotating them whenever the cron job runs instead of waiting for this limit.

My logrotate.d is the defaults --

Quote
weekly

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones
create

# uncomment this if you want your log files compressed
#compress

# packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp, or btmp -- we'll rotate them here
/var/log/wtmp {
    missingok
    monthly
    create 0664 root utmp
    rotate 1
}

/var/log/btmp {
    missingok
    monthly
    create 0660 root utmp
    rotate 1
}

# system-specific logs may be configured here

And the configuration for my apache logs -

Quote
/home/www/logs/*.log {
        olddir /home/www/logs/oldlogs/
        size 100M
        missingok
        rotate 300
        compress
        compressext .gz
        create 777 www www
        sharedscripts
                prerotate
                /usr/lib/cgi-bin/awstats.pl -update -config=mysite.com > /dev/null
        endscript
        postrotate
                /etc/init.d/apache2 reload > /dev/null
        endscript
}

I am confident my paths are correct, and if my understanding is correct, "size 100M" should only let it rotate logs over 100M? What is the problem?

rvtraveller

  • The very scary
  • Administrator
  • Hero Member
  • *****
  • Posts: 1192
    • View Profile
Re: Logrotate issue
« Reply #1 on: October 06, 2011, 08:13:43 AM »
I'm not sure what exactly the problem is with your configuration.  However, what version of Ubuntu are you running?  A friend of mine had similar issues with logrotate (not apache logs but logs just the same) and he ended up writing his own "logrotate" script to handle it.  I'll see if I can get a hold of him and see if he remembers anything.

rvtraveller

  • The very scary
  • Administrator
  • Hero Member
  • *****
  • Posts: 1192
    • View Profile
Re: Logrotate issue
« Reply #2 on: October 06, 2011, 08:16:49 AM »
Update:

Are you sure it isn't supposed to be:  size=100M

The man pages seem to indicate the "=" is necessary:  http://linuxcommand.org/man_pages/logrotate8.html

Mop

  • Hero Member
  • *****
  • Posts: 836
  • I POST CP
    • View Profile
    • Homepage
Re: Logrotate issue
« Reply #3 on: October 06, 2011, 09:51:12 AM »
It is ubuntu 11.04, 64 bit.

I hadn't noticed the equal signs in the manual's examples, I was going off of the "size size" in the section describing the size parameter. Most examples I found excluded the =. I'll try it though, moment.

Edit: yeah, that didn't make any difference. Perhaps I will make a python script to do it.
« Last Edit: October 06, 2011, 09:54:04 AM by Mop »