Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2001
    Location
    QLD, Australia
    Posts
    284

    PSA5 Log Removal and Compression Script

    Hey all,

    Ok, had a client ask for a script which would move the *.processed log files created by PSA5 into a tar.gz in the users httpdocs directory.

    Figured this might be useful to some others:

    ---- BEGIN COPY FROM HERE ---

    #!/usr/bin/perl -w

    # Use strict
    use strict;

    my @domainsList = ("domain1.com|domain1user", "domain2.com|domain2user");
    my $currentDomain;
    my $currentTime = time;
    $currentTime = localtime($currentTime);

    $currentTime =~ s/(.*)\d\d\:.*/$1/gi;
    $currentTime =~ s/\://gi;
    $currentTime =~ s/\s/\_/gi;

    foreach $currentDomain (@domainsList) {
    my($currentDomain, $currentUser) = split(/\|/, $currentDomain);
    system("mkdir -p /usr/local/psa/home/vhosts/$currentDomain/httpdocs/logs-gzip");
    system("tar -P -czf /usr/local/psa/home/vhosts/$currentDomain/httpdocs/logs-gzip/$currentTime.tgz /usr/local/psa/home/vhosts/$currentDomain/logs/*.processed");
    system("rm -fr /usr/local/psa/home/vhosts/$currentDomain/logs/*.processed");
    system("chown -R bblitz:psacln /usr/local/psa/home/vhosts/$currentDomain/httpdocs/logs-gzip");
    }

    --- END COPY ---

    Basically, copy and paste that into a file, dump it into your cron.daily directory and chmod it appropriately (700 will be fine).

    The ONLY variable you change is the

    my @domainsList = ("domain1.com|domain1user", "domain2.com|domain2user");

    Part, where you add your domains and their domain user as a pipe split pair.

    The end result is that for each domain the script will compress the *.processed log files daily and dump them into the httpdocs/logs-gzip directory.

    Ie. /usr/local/psa/home/vhosts/domain.com/httpdocs/logs-gzip .

    The filenames will be in date format;

    Mon_Nov__4_04.tgz
    Tue_Nov__5_04.tgz

    Enjoy,

    Stuart

    P.S. It ONLY works on PSA5.
    Seekbrain.com - Personal Blog
    E-Currency Australia - Crypto Currency Services

  2. #2
    Join Date
    Jun 2001
    Posts
    960
    Stuart, thanks for sharing the script!

    I just tested it and it worked perfectly, except that I had to change the last line to:

    system("chown -R $currentUser:psacln /usr/local/psa/home/vhosts/$currentDomain/httpdocs/logs-gzip/*");

  3. #3
    Join Date
    Dec 2001
    Location
    QLD, Australia
    Posts
    284
    Woops.

    My bad!

    Hope you find it useful.

    Stuart
    Seekbrain.com - Personal Blog
    E-Currency Australia - Crypto Currency Services

  4. #4
    Join Date
    Jun 2001
    Posts
    960
    Sure, it's a very useful script!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •