Мой /etc/logrotate.d/httpd
содержание файла
/var/log/httpd/access.log {
size=50M
dateext
maxage 90
postrotate
/usr/bin/killall -HUP httpd
ls -ltr /var/log/httpd/ | mail -s "$HOSTNAME: Apache restarted and log files rotated" info@email.com
endscript
}
в то время как мой /etc/logrotate.conf
# see "man logrotate" for details
# rotate log files weekly
weekly
# keep 4 weeks worth of backlogs
rotate 4
# create new (empty) log files after rotating old ones
create
# use date as a suffix of the rotated file
dateext
# 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 and btmp -- we'll rotate them here
/var/log/wtmp {
monthly
create 0664 root utmp
minsize 1M
rotate 1
}
/var/log/btmp {
missingok
monthly
create 0600 root utmp
rotate 1
}
Но в выходные, когда журнал, как ожидают, будет повернут, это не. Новый пустой файл создается, но остается пустым, в то время как последний повернутый файл продолжает расти. Затем после того, как я должен перезапустить httpd
сервис, чтобы начать регистрироваться снова.
Какова проблема?
Ваши журналы не были повернуты, потому что они еще не достигли размера 50 МБ.
Поскольку вы указали размер
, обычная ротация журналов на основе даты не выполняется вступят в силу. Вместо этого журнал поворачивается, когда он превышает указанный размер, даже если это время занимает больше недели, месяца или любого другого периода времени, указанного в ином случае.
Как видно на странице руководства:
size size
Log files are rotated only if they grow bigger than size bytes.
Если вы хотите ротацию журнала каждую неделю, но вы хотите повернуть его раньше , если он превышает 50 МБ, тогда используйте maxsize 50M
.
maxsize size
Log files are rotated when they grow bigger than size bytes even before
the additionally specified time interval (daily, weekly, monthly, or
yearly). The related size option is similar except that it is mutually
exclusive with the time interval options, and it causes log files to be
rotated without regard for the last rotation time. When maxsize is used,
both the size and timestamp of a log file are considered.