LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 04-05-2005, 02:57 PM   #1
jmanjohn61
Member
 
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, 03:44 PM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
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.
 
  


Reply



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 04:56 AM
shell script: delete all directories named directory.# except directory.N brian0918 Programming 3 07-13-2005 06:54 PM
auto delete old mails in sendmail - Pls Help maharajg Linux - Networking 3 11-10-2004 11:21 AM
rm can't delete 999999 files in one directory yelo Linux - Software 10 04-10-2004 02:00 PM
How can I delete a directory and its files? OrganicX Linux - General 6 09-01-2002 04:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:41 PM.

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