Linux Debian Logrotate
Documentation
- Official Doc
http://doc.ubuntu-fr.org/logrotate
- Unofficial Doc
http://www.admin-linux.fr/?p=1598
installation
- installation
apt-get install logrotate
- confirmation
logrotate
- configuration /etc/logrotate.conf
## logrotate.conf (logrotate)
#
# Description
# logrotate configuration file.
#
# Log compress before rotate :
compress
# Default rotate frequency :
daily
# do rotate even if empty
ifempty
# By default rotate is made 365,25 days per years
rotate 366
# remove too old archive
maxage 366
# send expire log by mail
maillast
# mail adress
mail fhh@admin-linux.fr
# if log doesn't exist don't send error
missingok
# add date to archive
dateext
# when archive is done on some logs, scripts pre and post rotate are exeuted once by file
# the option "sharedscripts" set it to once
sharedscripts
# change archive user and group.
create 0640 root root
# send archives in this folder
olddir /var/log/archives
# specify special archive log rotate for argus :
/var/log/argus/argus.log {
olddir /var/log/archives/argus
}
# Inclusion des scripts propres aux logs.
include /etc/logrotate.d
- folder
/etc/logrotate.d/
add a log rotate
- sample /etc/logrotate.d/apache2
/var/log/apache2/*.log {
daily
missingok
rotate 14
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
postrotate
if /etc/init.d/apache2 status > /dev/null ; then \
/etc/init.d/apache2 reload > /dev/null; \
fi;
endscript
prerotate
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
run-parts /etc/logrotate.d/httpd-prerotate; \
fi; \
endscript
}
execute a log rotate
logrotate --force /etc/logrotate.d/apache2