doodeman.org

Pruning a drive with perl

#!/usr/bin/perl
print "Starting\n";
if (-e '/tmp/prune.lock') {
        print "Already running, quitting\n";
        exit 0;
}

system("touch /tmp/prune.lock");

my $pct = 100;
my $filelist = `find /home/bittorrent/r/bittorrent -printf '%T+ %p\n' | sort | cut -d " " -f 2-`;
my @files = split(/\n/, $filelist);
while($pct > 96) {
        my $duinfo = `df -h`;
        if ($duinfo =~ /bittorrent.+ (\d+)\%/) {
                $pct = $1;
                print "pct is $pct\n";
                if ($pct > 96) {
                        my $delfile = shift(@files);
                        unlink($delfile);
                        print "Canning $delfile since pct is $pct\n";
                }
        } else {
                print "line: $duinfo\n";
                die "Cant get space stats!";
        }
}
my $emptydirs = `find /home/bittorrent/r/bittorrent/ -type d -empty`;
my @deldirs = split(/\n/, $emptydirs);
while(my $deldir = shift(@deldirs)) {
        $deldir =~ s/([^A-Za-z0-9\.\/])/\\$1/g;
        if ($deldir ne '/home/bittorrent/r/bittorrent/') {
                print "Removing empty dir $deldir\n";
                system("rm -rf $deldir");
        }
}

unlink('/tmp/prune.lock');

Great books about brain-]internet implants

I recently had a discussion with someone about brain implants. I pointed them to this amazing series: https://www.amazon.com/Minds-Eye-Nick-Hall-Book-ebook/dp/B00HVGGH76 . Great fictional series that really explores the near-future!

New car!

I got this car because the truck died. Sad. 2006 Mitsubishi Eclipse V6!

Image/photo
And now the A/C is broke. In 105 degree heat index weather. ONLY $1600 to fix! But I still love it.

Later posts Earlier posts