During day-to-day operations of your network, the different log files in the system start to add up. Depending upon how much security your networks are required to have, the audit logs and system logs can grow to a pretty big size. To alleviate this problem I came up with a very small script that I run as a cron job to ensure that my file system does not fill up. The script uses Solaris's "mtime" function. I have it set to save files up to seven days. Any log files after that are wiped from the system. This allows the administrator the ability to save the files to tape within seven days, before the files are removed.
This script removes old logs greater than one week (seven days).
NOTE: To change the length of retention, change the "7" to whatever length of days needed to keep the files on the system.
sync;sync
(file directory here) -mtime +7 -exec /usr/bin/rm {} ;
This was first published in January 2003
Disclaimer:
Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.
Join the conversationComment
Share
Comments
Results
Contribute to the conversation