Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Limit directory size script
Name: WebSoda Date: May 16, 2003 at 09:06:34 Pacific OS: ????? CPU/Ram: ???????
Comment:
Thanks to all in advance
I was wondering if anyone had a script that could be ran every few hours that would LIMIT the size of a directory. Here is the logical flow:
-Get total size of DIRECTORY -If DIRECTORY SIZE > 250MB Then -List all files in directory from OLDEST to NEWEST -Do a DIR on the directory and delete the first file found (which would be the oldest) -Loop back to Get total size of DIRECTORY to check again -End If -If DIRECTORY SIZE = 250MB Then -End If
Summary: The last one does not recurse. Try this: du -ks `find /var/stm/logs -type f` | sort +0rn | head -1 If you want a script, here you go: #!/bin/ksh du -ks `find $1 -type f` | sort +0rn | head -1 > /tmp...
Summary: I am developing a script that monitors directory sizes. The script send emails and pages when certain percentage thresholds are reached. My question is: how to implement functionality to stop paging...