Name | Modified | Size | Downloads / Week |
---|---|---|---|
apachelogrotate.1 | 2011-08-10 | 7.9 kB | |
apachelogrotate.pl | 2011-08-10 | 14.6 kB | |
README | 2011-08-10 | 3.8 kB | |
Totals: 3 Items | 26.4 kB | 0 |
TITLE apachelogrotate - rotate, compress and delete log files better than logrotate SYNOPSIS version 0.1.0 apachelogrotate [-v+] [-m maxsize] [-P n%| -D n] [logdir] DESCRIPTION Rotate apache log files better than logrotate. This is beta code. I use it in production but it might eat your head. This script works by checking if logfiles are too big, renaming them, restarting apache and using lsof to check if no one has the file open and only then compressing it. After rotating logs it will delete old logs if the partition is too full. It deletes based on age only. All logfiles are considered equal. Partition size and fullness are calculated from the output of df. FEATURES * This script waits until Apache has stopped writing to the logfiles and then compresses them. Logrotate either compresses them immediately or at the next rotation event. * This script can be run multiple times in one day. Logs are suffixed with a date and time. Logrotate can only run once a day. This is important because compression works so well with text logfiles and a file which is eating your whole partition in 1/2 a day can be managed if you run your log rotation script 2 times a day. * This script deletes old logs based on partition fullness. Logrotate lets you specify number of logs to keep, but that's just a proxy for what you really care about which is the fullness of the partition. WHY I SUCK * This script is not very flexible. It does what I want and if that's not what yuou want, you're out of luck. * All logfiles are deleted based on age only. If you want to keep access logs longer than error logs, you're out of luck again. * This script depends on lsof and df and has only been tested on my linux system. If it works in windows, I'll eat my hat. * This script relies on lsof to determine if Apache is still writing to logs. If anyone has the log open, we assume it's Apache. If someone else was reading a log file when we rotated it, this script would think Apache still had it open and possibly time out. OPTIONS --verbose or -v What you think it is. -v -vv -vvv all do stuff --maxzise size or -m size How big log files need to be to cause them to be rotated. Default is 50M (52428800 bytes) --logdir or -l or -d Where to look for the log files. Default is /var/log/httpd --lsof_interval seconds How long in seconds to sleep between lsof checks of logfiles to see if Apache has really stopped writing to it. Default is 30 seconds. --timeout seconds How long to keep checking if Apache has stopped writing to a file in total. At the end of each --lsof_interval, we total up all the time that this script has been checking and compressing files and then bail out if it's been longer than this value. Default is 900 seconds or 15 minutes. --testing or -t Testing mode. Nothing will actually get changed. No files will be renamed or compresed or deleted. Apache will not be restarted. --no_restart Do not restart Apache after log rotation. --partition_max_full or --p_max or -P If the partition containing the logdir is more than this amount full, delete enough files to bring it down to this level. This is a 2 digit percentage. Default is 80. --delete_n_kbytes or --del or -D Delete enough old log files to clear up this many kilobytes of space. If this is specified, this many kbytes worth of files will be deleted regardless of if fiels were rotated. partition_max_full is ignored if this is specified.