View Single Post
  #4   (View Single Post)  
Old 14th July 2008
ocicat ocicat is offline
Join Date: Apr 2008
Posts: 3,298

Originally Posted by disco View Post
thanks for the link, but this seems to only remove files over n days. What I need to do is when the hard disk is greater the n percent full, remove the oldest files from the directory until the disk is lower than n percent full.
Here are some hints you can use to help yourself:
  • The following tutorial is a good introduction to shell programming:
  • To determine whether a partition is more than some pre-determined percentage full, look the output of df(1) & think about how to isolate a value in a particular column (HINT: with awk(1), this is easy...).
  • As for how to determine how old files are, look at the manpage for ls(1).
The link provided by jggimi will help you ferret out the details needed to set up cron(8) which can automatically call your script on whatever periodic basis you want.

Last edited by ocicat; 14th July 2008 at 05:44 PM.
Reply With Quote