orbadelic has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w #Script to roll log files over nightly and HUP httpd use Date::Calc qw(Today); #function declarations sub graceful(); ($year,$month,$day) = Today(); $logdir = "/var/log"; $logname = "httpd-access.log"; $timestamp = "$year$month$day"; $apachectl = "/usr/local/sbin/apachectl"; $gzip = "/usr/bin/gzip"; if (-e "$logdir/$logname" && !-e "$logdir/$logname.$timestamp") { rename("$logdir/$logname", "$logdir/$logname.$timestamp"); graceful(); } else { print "Cannot rotate log to pre-existing timestamp\n"; } if (-e "$logdir/$logname.$timestamp" && !-e "$logdir/$logname.$timesta +mp.gz") { system("$gzip $logdir/$logname.$timestamp"); } else { print "file already exists"; } sub graceful() { system("$apachectl graceful"); #restart apache gracefully }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: suggestions for log rotater...
by Masem (Monsignor) on Nov 05, 2001 at 06:13 UTC | |
by Starky (Chaplain) on Nov 05, 2001 at 11:51 UTC | |
by Rhose (Priest) on Nov 05, 2001 at 23:55 UTC | |
|
Re: suggestions for log rotater...
by Aighearach (Initiate) on Nov 05, 2001 at 06:26 UTC | |
|
Re: suggestions for log rotater...
by kschwab (Vicar) on Nov 05, 2001 at 06:20 UTC | |
|
Re: suggestions for log rotater...
by orbadelic (Acolyte) on Nov 05, 2001 at 06:54 UTC |