Quick Linux Scripts
Wednesday, April 7th, 2004The need to find Linux files above size-x always seems to come up. I typically nail down the syntax to the find command after referencing the man pages and/or a quick google search. The following will find files in /var:
find /var -size +100000k
I finally had time to play with logrotate. It’s surprising simple and easy to use. Here is an example script that will rotate apache logs when they reach 30M or that are 1 day old (controlled by cron.daily):
/var/log/httpd/httpsd_access_log /var/log/httpd/httpsd_error_log {
missingok
size=30M
sharedscripts
postrotate
/bin/kill -HUP `cat /usr/local/apache/logs/httpd.pid 2>/dev/null` 2> /dev/null || true
endscript
}