#740 more robust log rotation

This commit is contained in:
Oliver Gorwits
2021-02-10 13:25:55 +00:00
parent 1fc44220cb
commit b7ac3a3bd5
3 changed files with 12 additions and 6 deletions

View File

@@ -1,3 +1,9 @@
2.047003 - 2021-02-10
[BUG FIXES]
* #740 more robust log rotation
2.047002 - 2020-12-30
[NEW FEATURES]

View File

@@ -167,9 +167,9 @@ sub rotate_logs {
return unless (-f $log_file) and
((-s $log_file) > ($logsize * 1024768));
my @files = glob file($log_dir, '*');
foreach my $f (reverse sort @files) {
next unless $f =~ m/$log_file\.(\d)$/;
my @files = grep { /$log_file\.\d+/ } glob file($log_dir, '*');
foreach my $f (sort { $b <=> $a } @files) {
next unless $f =~ m/$log_file\.(\d+)$/;
my $pos = $1;
unlink $f if $pos == ($logfiles - 1);
my $next = $pos + 1;

View File

@@ -182,9 +182,9 @@ sub rotate_logs {
return unless (-f $log_file) and
((-s $log_file) > ($logsize * 1024768));
my @files = glob file($log_dir, '*');
foreach my $f (reverse sort @files) {
next unless $f =~ m/$log_file\.(\d)$/;
my @files = grep { /$log_file\.\d+/ } glob file($log_dir, '*');
foreach my $f (sort { $b <=> $a } @files) {
next unless $f =~ m/$log_file\.(\d+)$/;
my $pos = $1;
unlink $f if $pos == ($logfiles - 1);
my $next = $pos + 1;