Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi
I am looking for a shell script to delete old files whenever storage limit is crossed for a folder. That would be great if anyone point me in the right direction in finding a simple way to do this?
Thanks in advance

I'll give you part of it: This find command files the 100 oldest files:# untested, doesn't support files with spaces
find . -type f -print | xargs ls -ltr |head -100To delete those files, just add this to the end of the command
|xargs rm

The best way to do this is to implement user quota. This way users won't be able to add more files once they've reached their set quota. As opposed to deleting files once they've gone over it. There's a chance you will delete that very important file that they need the most!Anyway, this script searches, recursively, the current directory for folders that are larger than 1GB and prints them.
find ./ -type d -size +1G
This one search for folders in the current directory that are larger than 1GB without walking deeper than one level
find ./ -maxdepth 1 -type d size +1G
Feel free to get in touch if you have any question.
Regards
JoeFully Managed Dedicated Servers - http://www.unixy.net/?page=dedicated
joe@unixy.net

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |