[mdlug] Script to delete old files?

Stan Green Stan at mcomputersolutions.com
Mon Feb 28 20:31:39 EST 2011


I have a system where I would like to have at least 25% disk space free, which 
is checked at boot up. (Yes, it is booted on a weekly basis.) The box has files 
that have been copied to another box, so they can be safely deleted without 
user interaction. (I keep them after the copy as a safeguard)

My thought is a script something like this (pseudo code):
df > FreeSpace 
if FreeSpace is less then 25%
if FreeSpace is less then 50% do 
	delete the oldest file
	df > FreeSpace
Loop until FreeSpace is greater then 50%

Does this make sense (i.e. I'm on the right track!) or is there a better way to 
accomplish this task?

Thanks,
Stan Green



More information about the mdlug mailing list