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?
|
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. |
All times are GMT -5. The time now is 01:50 AM. |