So i'm working on a script to remove some old backups when the disk space available goes bellow a certain percentage.
# get disk info
$handle = Filesys::DiskFree->new();
$handle->df();
$available = $handle->avail("$dir");
$used = $handle->used("$dir");
$total = $handle->total("$dir");
$used_p = ($used / $total) * 100.0;
print "$used_p\n";
print "$used\n";
# find files to delete
# --- special sauce code to find @files
# delete files
unlink @files;
# get new disk info
$handle = Filesys::DiskFree->new();
$handle->df();
$available = $handle->avail("$dir");
$used = $handle->used("$dir");
$used_p = ($used / $total) * 100.0;
print "$used_p\n";
print "$used\n";
My thinking was that the second time i used Filesys::DiskFree I would get the new df values which should reflect the files deleted. However, is not giving me the values i expect. Is not exactly the same, but the difference is not nearly as much as I expect. However the second time i run it I can see that the initial print reflects the files being deleted on the previous run. It is as if there was some sort of delay. As shown above, I tried calling new() again to see if that would clear stale data.