[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cobalt-users] Re: log files & rotation



A. Lantink wrote on 11.09.2001:

> In the files /etc/logrotate.d/site1  ....site2 etc is configured when the
> site logs(web.log,ftp.log and mail.log) are rotated.
> Does anyone know where the template for this file is??
> This file is automatically generated for each virtual site. I want to rotate
> the logs once a day, and not at an set size. And i don't like to edit echt
> file manually, editing the templete ismore easy.

I don't know the template but I have a script allsites-logrotate.cgi
located in /etc/cron.daily that works:



#!/usr/bin/perl

system(rm -f /etc/logrotate.d/site*);
system(rm -f /etc/logrotate.onboot/site*);
system(rm -f /etc/logrotate.d/home);
system(rm -f /etc/logrotate.onboot/home);

open(LOGROTATEDATEI, ">/etc/logrotate.d/allsites") || die "Could not open /etc/logrotate.d/allsites\n";

  print LOGROTATEDATEI "/home/sites/home/logs/mail.log {\n   missingok\n   compress\n   size 200k\n}\n\n";
  print LOGROTATEDATEI "/home/sites/home/logs/ftp.log {\n   missingok\n   compress\n   size 200k\n}\n\n";
  print LOGROTATEDATEI "/home/sites/home/logs/web.log {\n   missingok\n   compress\n   size 2M\n}\n\n";

  for ($i=1; $i<=200; $i++) {
    print LOGROTATEDATEI "/home/sites/site".$i."/logs/mail.log {\n   missingok\n   compress\n   size 200k\n}\n\n";
    print LOGROTATEDATEI "/home/sites/site".$i."/logs/ftp.log {\n   missingok\n   compress\n   size 200k\n}\n\n";
    print LOGROTATEDATEI "/home/sites/site".$i."/logs/web.log {\n   missingok\n   compress\n   size 2M\n}\n\n";
  }
  
close(LOGROTATEDATEI);



Replace "size 200k" / "size 2M" with "daily" and you should have that
what you are looking for. This script will delete all site-specific
logrotate files and will create one file "allsites"with the
logroate-configuration for all sites.

If you have more than 200 sites per RaQ change $i<=200 to any value
you want. It does not matter if you have less than $i sites.

You should place this script in /etc/cron.daily because the GUI will
create a siteXY-file each time you'll change the site-quota for a
specific site XY. You should name the script so it executes (chmod
700) prior the job called "logrotate".


Regards,
Daniel

-- 
free backup-solution for your RaQ:
http://www.dnid.de/cobalt/raqbackup/