Help for this page

Select Code to Download


  1. or download this
    use strict;
    use warnings;
    ...
    
    # test it:
    print partition_usage('/home/'), "\n";
    
  2. or download this
    my @files = glob 'logfile_*.log.gz';
    @files = reverse sort { -M $a <=> -M $b } @files.
    
  3. or download this
    my $limit = 10 * 1024**3; # 10 GB
    for my $filename (@files) {
        last if partition_usage('/var/log/') < $limit;
        unlink $filename or warn "Can't delete file '$filename': $!";
    }