> It seems that each time I attempt to write a script for something like > this, the next day I see one that replaces my 46 lines of code with one > (and actually works). So before I create my usual kludge, can anyone > point me at a good way to do the following? > > I create backups each day in directories named for the date in the form > YYYY-MM-DD. I would like to keep as many of these online as I can, so > to do this I need a script to look at the percentage used of my backup > partition and delete the oldest backups until reaching a given > threshold. I guess in pseudo-code it would be something like: > > while free-space < threshold do > rm -rf the-oldest-backup > done > > I can get the free (or used) percentage by parsing the output from df I > guess (using awk maybe?), but maybe there's a better way to do that. As > the directory names sort by default with oldest first, I guess there's > an easy way to say the-oldest-backup. >
You can used the find command to search for files older than a certain date: find . -mtime +7 You can also use ls to order by date: ls -ltr or ls -lt Then use head or tail to grab the bottom or top entries. To get the free space you can use df: df -h To get space within a directory use du: du -h -- The Digital Hermit Unix and Linux Solutions http://www.digitalhermit.com [EMAIL PROTECTED]
Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com