#23 Disk Space Alarm

I ran out of disk space today. I was working on a program that produced a number of huge core dumps and filled up my disk. Of course I didn't notice it until I started to do a compile and found that my object files were getting truncated. It would have been nice to learn of the problem sooner. As it turned out, because the build broke, I was forced to clean out the core files and restart the build from scratch.

This script tells everyone when disk space is low.

The Code

 1 #!/usr/bin/perl 2 use strict; 3 use warnings; 4 5 use Filesys::DiskSpace; 6 7 my $space_limit = 5; # Less than 5%, scream 8 9 if ($#ARGV == -1) { 10 print "Usage is $0 <fs> [<fs>....]\n"; 11 exit (8); 12 } 13 14 # Loop through each directory in the 15 ...

Get Wicked Cool Perl Scripts now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.