Visit the LQ Articles and Editorials section
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 04-05-2005, 03:57 PM   #1
Registered: Dec 2003
Distribution: FC2
Posts: 38

Rep: Reputation: 15
Auto Delete oldest files @ratex when directory is 98% full

I need something to delete files when the drive/partition is 98-99% full. The automatic delete needs to run regularly. Anyone have any ideas?
Old 04-05-2005, 04:44 PM   #2
Senior Member
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 58
Maybe a script which looks at the percent used.....
num=`df -h /home |grep "/dev" | awk '{print$5}'`

If that percent is greater than some number....
if [ $num -gt some_number ]; then

Then use find to remove files which are older than a particular age....
find /home -type f -name '*.jpg' -mtime +90 -exec rm {} \;

Then put the script in a cron job to run when you want.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Script to delete files with 0k file size in a directory justgiver Linux - Newbie 4 01-28-2008 05:56 AM
shell script: delete all directories named directory.# except directory.N brian0918 Programming 3 07-13-2005 07:54 PM
auto delete old mails in sendmail - Pls Help maharajg Linux - Networking 3 11-10-2004 12:21 PM
rm can't delete 999999 files in one directory yelo Linux - Software 10 04-10-2004 03:00 PM
How can I delete a directory and its files? OrganicX Linux - General 6 09-01-2002 05:25 AM

All times are GMT -5. The time now is 10:28 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration