The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Access Logs Question

Discussion in 'General Discussion' started by dkla, Nov 2, 2004.

  1. dkla

    dkla Registered

    Joined:
    Oct 28, 2004
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    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
     
  2. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    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");
    }
    
    
     
Loading...

Share This Page