#!/usr/bin/perl -Tw
use strict;
$ENV{PATH}='/bin:/usr/bin';

die "bad guy" unless getpwuid($<) =~ /^(root|nobody)$/;
my @LOGFILES = qw(access_log error_log);
my $gzip_exec = "/usr/bin/gzip";
umask 0;
my ($sec,$min,$hour,$mday,$mon,$year) = localtime(time);
my $time = sprintf "%0.2d",$mday%10;
$^I = ".".$time;
@ARGV = @LOGFILES;
while (<>) {
  close ARGV;
}

# compress log files
foreach (@LOGFILES) {
    system "rm $_.$time.gz; $gzip_exec $_.$time";
}
