Hi, I am trying to make a log rotator and found a great perl script to do it
but, would really like it in PHP (one less langauge to maintain).
I know the system has "things" in place to do this but, I don't have access
to the system /etc/log/ folder or the system log rotation scripts. I figured
a simple php command line script would be a good alternative to maintain my
own logs.
Here's the perl script:
#!/usr/bin/perl
$LOGPATH='/Users/cv_admin/mylogs';
@LOGNAMES=('housekeeper_log_deleter.log','mysqlbackups_deleter.log','webbac
kups_deleter.log');
$MAXCYCLE = 4;
chdir $LOGPATH; # Change to the log directory
foreach $filename (@LOGNAMES) {
for (my $s=$MAXCYCLE; $s >= 0; $s-- ) {
$oldname = $s ? "$filename.$s" : $filename;
$newname = join(".",$filename,$s+1);
rename $oldname,$newname if -e $oldname;
}
}
Don Myers
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php