
Estou tentando configurar o logrotate. Estou obtendo resultados inesperados; alguns arquivos de log têm várias datas e/ou zero bytes de tamanho. Gostaria de ter um log para cada dia e ter a data no nome do arquivo do log antigo, mantendo apenas os logs dos últimos 30 dias.
aqui está minha entrada no logrotate
/var/www/html/joomla-1.x/example.com/logs/*.log {
missingok
daily
dateext
extension .log
rotate 30
notifempty
sharedscripts
nocompress
postrotate
/sbin/service httpd reload > /dev/null 2>/dev/null || true
endscript
}
a seguir estão os arquivos de log que foram girados.
[root@Webserver-2 logs]# ls -la
total 72460
drwxrwxr-x. 2 apache apache 28672 Jan 13 03:08 .
drwxrwxr-x. 4 apache apache 4096 Nov 21 12:51 ..
-rw-r--r--. 1 root root 20367769 Jan 8 03:42 access-20140108-20140110-20140112.log
-rw-r--r--. 1 root root 0 Jan 12 03:08 access-20140108-20140110.log
-rw-r--r--. 1 root root 0 Jan 10 03:38 access-20140108.log
-rw-r--r--. 1 root root 9925777 Jan 9 03:21 access-20140109-20140111-20140113.log
-rw-r--r--. 1 root root 0 Jan 13 03:08 access-20140109-20140111.log
-rw-r--r--. 1 root root 0 Jan 11 03:26 access-20140109.log
-rw-r--r--. 1 root root 9961813 Jan 10 03:37 access-20140110-20140112.log
-rw-r--r--. 1 root root 0 Jan 12 03:08 access-20140110.log
-rw-r--r--. 1 root root 10114757 Jan 11 03:25 access-20140111-20140113.log
-rw-r--r--. 1 root root 0 Jan 13 03:08 access-20140111.log
-rw-r--r--. 1 root root 10640709 Jan 12 03:08 access-20140112.log
-rw-r--r--. 1 root root 10069927 Jan 13 03:07 access-20140113.log
-rw-r--r--. 1 root root 908253 Jan 13 08:59 access.log
-rw-r--r--. 1 root root 622524 Jan 8 03:39 error-20140108-20140110-20140112.log
-rw-r--r--. 1 root root 0 Jan 12 03:08 error-20140108-20140110.log
-rw-r--r--. 1 root root 0 Jan 10 03:38 error-20140108.log
-rw-r--r--. 1 root root 258401 Jan 9 03:18 error-20140109-20140111-20140113.log
-rw-r--r--. 1 root root 0 Jan 13 03:08 error-20140109-20140111.log
-rw-r--r--. 1 root root 0 Jan 11 03:26 error-20140109.log
-rw-r--r--. 1 root root 291228 Jan 10 03:37 error-20140110-20140112.log
-rw-r--r--. 1 root root 0 Jan 12 03:08 error-20140110.log
-rw-r--r--. 1 root root 305361 Jan 11 03:22 error-20140111-20140113.log
-rw-r--r--. 1 root root 0 Jan 13 03:08 error-20140111.log
-rw-r--r--. 1 root root 292764 Jan 12 03:04 error-20140112.log
-rw-r--r--. 1 root root 283243 Jan 13 02:59 error-20140113.log
-rw-r--r--. 1 root root 30299 Jan 13 08:58 error.log
-rw-r--r--. 1 apache apache 919 Dec 23 08:11 error.php
[root@Webserver-2 logs]#
Responder1
O problema com sua configuração é que você também rotaciona arquivos de log que já foram rotacionados definindo extension .log
e usando o /var/www/html/joomla-1.x/example.com/logs/*.log
curinga.
Repita a estrofe enquanto nomeia explicitamente /var/www/html/joomla-1.x/example.com/logs/access.log
e /var/www/html/joomla-1.x/example.com/logs/error.log
/ou remova a extension .log
opção.