//View Tip #363
Similar Tips
» Find last modified files on a filesystem
» Delete old files
» List only the files that have been updated today.
» Find files by mime-type
» Randomized find


Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
This is a script that I recently wrote to find the logs of my IDP that were over 90 days old and delete them.

The script is pretty much self explanatory.

## Lets find the log directories that are over 90 Days old.
find /var/netscreen/DevSvr/logs -mtime +90 -type d -prune -print > /root/scripts/files-deleted

## Now let's log the directories we are going to delete.
touch /root/scripts/deletelog

## We want to know when the files were deleted so we will append that to the log file.
date >> /root/scripts/deletelog

## Now we go through and delete the directories that are over 90 days old
## and log the directories that we delete to the log file.
for FILE in `cat /root/scripts/files-deleted`
echo Deleting $FILE ... >> /root/scripts/deletelog
rm -Rf $FILE

## Finally we will email a copy of the log file to the admin for his/(or her) review.
cat /root/scripts/deletelog | mail -s "90 Day IDP log cleanup" youremailaddress@domian.com

View Comments »


Add your comment

Comments are currently disabled
No Comments

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit