dkla

Registered
Oct 28, 2004
1
0
151
Hi,

I am looking for a WHM AND CPanel combination of settings that will move my users raw logs from usr/local/apache/domlogs to their home directory /home/user/logs/ every day.
I know it can be done (I've seen it as a customer) but I can't replicate it as a host manager.

All I know is that the user has to select "Archive Logs in your home directory at the end of each month" under Raw Log Manager in CPanel. Doing only this didn't work so I am assuming that I'm missing a WHM setting.

thanx
 

PWSowner

Well-Known Member
Nov 10, 2001
2,901
4
343
ON, Canada
code to copy domlogs to users directories

Save this script somewhere as whatever you want to call it and set a cron job to run it. It will copy all users main domain log file from domlogs to their own "logs" directory.

Code:
#!/usr/bin/perl

@users = `ls -A1 /var/cpanel/users`;

foreach (@users) {
  chomp $_;

  if (! -e "/home/$_/logs") {
    mkdir("/home/$_/logs",0755);
  }

  open(FILE,"/var/cpanel/users/$_");
  @lines = <FILE>;
  close(FILE);

  foreach $l (@lines) {
    if ($l =~ /^DNS=/) {
      (undef,$url) = split(/=/, $l);
    }
  }

  chomp $url;

  system ("cp /usr/local/apache/domlogs/$url /home/$_/logs/$url");
  system ("chown $_.$_ /home/$_/logs/$url");
}