Rotating your log files will save you a bunch of space from bloated web logs growing out of control. Logrotate is easily customisable to suit any needs.
To force logrotate to rotate out of schedule use the f flag, and to make it output to screen, use V for verbose ie.
/usr/sbin/logrotate -vf /etc/logrotate.conf
Below is an excerpt for Logrotate configured with lighttpd. you will need to reload your specific web server with its own reload command.
nano /etc/logrotate.conf
# rotate log files weekly
weekly
# keep 4 weeks worth of backlogs
rotate 4
# create new (empty) log files after rotating old ones
create
# uncomment this if you want your log files compressed
#compress
# RPM packages drop log rotation information into this directory
include /etc/logrotate.d
# no packages own wtmp -- we'll rotate them here
/var/log/wtmp {
monthly
minsize 1M
create 0664 root utmp
rotate 1
}
# system-specific logs may be also be configured here.
/srv/www/mywebsite.com/logs/*log {
rotate 14
daily
compress
create 0664 lighttpd lighttpd
delaycompress
sharedscripts
postrotate
/sbin/service lighttpd reload > /dev/null 2>/dev/null || true
endscript
}
Comments are closed.