//View Tip #363
» Directory Tree
» Find files by modified time
» Randomized find
» Random mass-rename
Similar Tips
» Remove empty directories» Directory Tree
» Find files by modified time
» Randomized find
» Random mass-rename
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.
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` do echo Deleting $FILE ... >> /root/scripts/deletelog rm -Rf $FILE done ## 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
Comments
Add your comment
Comments are currently disabled
No Comments

