[mdlug] Script to delete old files?

Stan Green Stan at mcomputersolutions.com
Tue Mar 1 12:24:07 EST 2011


On Tuesday 01 March 2011 11:34:01 am David McMillan wrote:
> On 3/1/2011 8:52 AM, Carl T. Miller wrote:
> > Stan Green wrote:
> >> 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%
> >
> > This would work, although if you have a lot of files it
> > might run for a long time.  A way to speed it up would
> > be to delete files older than X weeks/days/hours/minutes.
> > If this runs every week, you could have it count down
> > from 8 weeks to 1 week.  The find command could be used
> > to find and delete the files relatively quickly.
>
>      Or... since the files he wants to delete are already copied to a
> remote machine, would it be practical to generate a list of files
> duplicated in both locations using rsync or fslint, and delete the local
> copies?
Yes, this would keep me form finding the oldest.

Would this not just change line: 
delete the oldest file
to:
delete the first file in the list (First In First Out)

Or is there more to this?

Thanks,
Stan



More information about the mdlug mailing list