Search the web
Sign In
New User? Sign Up
linux · This is a mailing list for Linux
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
log roatation / delete for virtual domains   Message List  
Reply | Forward Message #53471 of 56689 |
Re: [linux] log roatation / delete for virtual domains

On Fri, 6 Jun 2008 13:05:34 +0530
"Agnello George" <agnello.dsouza@...> wrote:

> this thing is i would have to keep editng the logrotate.conf flile.
> which is not possible for 100's of domain. Does does logrotae have a
> command line utility where i can jsut specify the date from which to
> delete the logs files . My log files are in the following format :
> total 676K
> 8.0K drwx--x--x 2 agnello agnello 4.0K Jun 5 19:56 .
> 8.0K drwx--x--x 9 agnello agnello 4.0K Jun 3 20:33 ..
> 196K -rw-r--r-- 1 root root 188K Jun 5 20:06
> agnello.sys.qualiproj.access_log
> 8.0K -rw-r--r-- 1 root root 288 Jun 3 20:05
> agnello.sys.qualiproj.access_log.1212503690

...

Well, there are lots of ways around this problem. 100's of domains is
no problem, you can do that by hand, try 10,000's.

Why not have this automated? Have yourself a list of domains, like this:

Inside logrotate.conf, you specify an include directory, in this
example we'll use /usr/local/etc/domains/virtual/conf.

This file consists of vritualdomainname:directoryname

/usr/local/etc/domains/virtual/logrotate.list:

example.test:example.test
housing.example.test:housing.example.test
schooling.example.test:schooling.example.test
...

So, in the rebuild script you might use something like this


#!/usr/bin/perl

use strict;
use warnings;

my %config;

sub set_config {
$config{'logrotateconf'} =
"/usr/local/etc/domains/virtual/logrotate.list";
$config{'logrotatedir'} =
"/usr/local/etc/domains/virtual/conf";
}

sub make_logrotate {
my $host_name = shift;
my $path_name = shift;

open( F, ">$path_name" )
or die( "cannot create $path_name:$!" );
print( F
"/var/www/sites/$path_name/log/*.log {
missingok
daily
create 0664 www-data www-data
rotate 5
prerotate
/root/website.sh /var/www/sites/$path_name
endscript

postrotate
apache2ctl graceful
endscript
}
" );
close(F);
}

sub build_virtual_logrotate {
open( F, $config{'logrotateconf'} )
or die( "cannot open ${config{'logrotateconf'}}:$!" );
while( <F> ) {
chomp;
if( $_ =~ /^(.*):(.*)$/ ) {
# although not really used, $1 allows you some
future flexibility if you need to pass the actual virtual name to the
make_logroate function
make_logrotate( $1, $2 );
}
}
close(F);
}

sub main {
build_virtual_logrotate();
}

set_config();
main();



--
The 14.4 dialup to the demarc is unreliable because of a trailing space
in /etc/netgroups. Microsoft is rolling a bone.
:: http://www.s5h.net/ :: http://www.s5h.net/gpg.html


[Non-text portions of this message have been removed]




Fri Jun 6, 2008 7:37 pm

psy80uk
Offline Offline
Send Email Send Email

Forward
Message #53471 of 56689 |
Expand Messages Author Sort by Date

HI I have atleast 20 virtual host on my Apache ( 2.2.8 ) server and am having a difficulty in deleting the logs after it reaches a certain limit. my vhost...
Agnello George
agnello_open...
Offline Send Email
Jun 5, 2008
7:21 am

... Personally I'd suggest that you use the more traditional approach of using logrotate for this. Apache shouldn't be in charge of log rotation, some...
ed
psy80uk
Offline Send Email
Jun 5, 2008
7:25 pm

... having ... http://192.168.0.244/>>> ... agnello.com/logs/agnello.sys.qualiproj.access_logcombined ... after ... logrotate. this thing is i would have to...
Agnello George
agnello_open...
Offline Send Email
Jun 6, 2008
7:45 am

On Fri, 6 Jun 2008 13:05:34 +0530 ... ... Well, there are lots of ways around this problem. 100's of domains is no problem, you can do that by hand, try...
ed
psy80uk
Offline Send Email
Jun 6, 2008
7:37 pm

... Very interesting , i will try this , first i have to understand the script that u have written :-) Thanks again -- Regards Agnello Dsouza ...
Agnello George
agnello_open...
Offline Send Email
Jun 7, 2008
5:53 am

On Sat, 7 Jun 2008 11:17:54 +0530 ... Well if you understand the principle then you can re produce it in another form that you understand, maybe sh or python?...
ed
psy80uk
Offline Send Email
Jun 7, 2008
11:52 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help