Perlboy
11-05-2002, 08:05 AM
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. :)
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. :)
