Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Wed Jun 20, 2012 3:14 pm 
Offline
Junior Member

Joined: Wed Jun 13, 2012 2:38 am
Posts: 27
I'm trying to limit the size of my log files for my web folder. access.log is getting so large that it is taking a while to access it.
It seems that I've done something because there are new log files created, but my log folder looks like this:

Quote:
access.log 0
error.log 0
access.log.1 0
error.log.1 0
access.log.2 80,413,564
error.log.2 3,718,266


Obviously, the log is rotating, but the information is all coming along to the new log rather than staying behind in the archive log.

Here is what I have. I added the following to /etc/logrotate.conf:

Quote:
# system-specific logs may be configured here
/home/user/public/website.org/log/*.log {
missingok
daily
rotate 30
create 640 root user
}


My /etc/cron.daily/logrotate looks like:

Quote:
#!/bin/sh

test -x /usr/sbin/logrotate || exit 0
/usr/sbin/logrotate /etc/logrotate.conf


Also, I'm not sure what the "test -x" line is about. Can I delete that??

Thanks in advance for any advice.


Top
   
PostPosted: Wed Jun 20, 2012 4:44 pm 
Offline
Senior Member
User avatar

Joined: Sat Aug 30, 2008 1:55 pm
Posts: 1739
Location: Rochester, New York
You need to reload apache after rotating log files, otherwise it'll keep writing to the old log file since it still has it open. From /etc/logrotate.d/apache2 on one of my systems,

Code:
/var/log/apache2/*.log {
        weekly
        missingok
        rotate 52
        compress
        delaycompress
        notifempty
        create 640 root adm
        sharedscripts
        postrotate
                if [ -f "`. /etc/apache2/envvars ; echo ${APACHE_PID_FILE:-/var/run/apache2.pid}`" ]; then
                        /etc/init.d/apache2 reload > /dev/null
                fi
        endscript
}


The 'postrotate' part is the key.

_________________
Code:
/* TODO: need to add signature to posts */


Top
   
PostPosted: Wed Jun 20, 2012 5:17 pm 
Offline
Junior Member

Joined: Wed Jun 13, 2012 2:38 am
Posts: 27
Thanks!

I'm a little afraid to copy and paste this exact code to the bottom of my config. Is there anything in there that I may need to change since I'm referencing the web access logs?

Quote:
postrotate
if [ -f "`. /etc/apache2/envvars ; echo ${APACHE_PID_FILE:-/var/run/apache2.pid}`" ]; then
/etc/init.d/apache2 reload > /dev/null
fi
endscript


Or will this addition do the trick do you think?


Top
   
PostPosted: Wed Jun 20, 2012 5:34 pm 
Offline
Junior Member

Joined: Wed Jun 13, 2012 2:38 am
Posts: 27
Now this is happening:

Quote:
* Reloading web server config apache2
httpd not running, trying to start
(13)Permission denied: make_sock: could not bind to address [::]:80
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs [fail]


Please help if you have an idea of what I may have done. Thanks!


Top
   
PostPosted: Wed Jun 20, 2012 5:36 pm 
Offline
Senior Member
User avatar

Joined: Sat Aug 30, 2008 1:55 pm
Posts: 1739
Location: Rochester, New York
Which distribution are you running, and which web server are you using? I assumed you were using Apache, which was probably incorrect.

_________________
Code:
/* TODO: need to add signature to posts */


Top
   
PostPosted: Wed Jun 20, 2012 5:39 pm 
Offline
Junior Member

Joined: Wed Jun 13, 2012 2:38 am
Posts: 27
I am. I'm running Ubuntu 10.04.

I've deleted the entire system specific log configuration and it is still not reloading apache2.

I really appreciate your help!


Top
   
PostPosted: Wed Jun 20, 2012 5:45 pm 
Offline
Junior Member

Joined: Wed Jun 13, 2012 2:38 am
Posts: 27
My ports.config file (I saw this was one possible issue, but mine seems OK):
Quote:
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz

NameVirtualHost *:80
Listen 80

<IfModule mod_ssl.c>
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to <VirtualHost *:443>
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
Listen 443
</IfModule>

<IfModule mod_gnutls.c>
Listen 443
</IfModule>


Top
   
PostPosted: Wed Jun 20, 2012 5:48 pm 
Offline
Junior Member

Joined: Wed Jun 13, 2012 2:38 am
Posts: 27
Nevermind. Stupid mistake.


Top
   
PostPosted: Wed Jun 20, 2012 6:01 pm 
Offline
Junior Member

Joined: Wed Jun 13, 2012 2:38 am
Posts: 27
I'm learning (only a week into building a vps and I have no coding background) and I really appreciate your patience. I have it all correctly functioning now including your very helpful script! logs are now turning over properly.
The reason I couldn't reload apache was because I forgot that I had not su root. All that was required was sudo!

Like I said. Stupid mistake. :)


Top
   
PostPosted: Thu Jun 21, 2012 6:23 am 
Offline
Senior Member
User avatar

Joined: Sat Aug 30, 2008 1:55 pm
Posts: 1739
Location: Rochester, New York
Cool! Good to know it is working. logrotate is right up there with etckeeper and sl on my should-be-installed-on-every-system list. :-)

_________________
Code:
/* TODO: need to add signature to posts */


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group