El día 23 de abril de 2013 12:02, fernando sainz
<fernandojose.sainz@gmail.com> escribió:
El día 23 de abril de 2013 11:40, <maykel@maykel.sytes.net>
escribió:
El 2013-04-23 11:27, fernando sainz escribió:
2013/4/23 <maykel@maykel.sytes.net>:
Hola muy buenas, tengo configurado logrotate para que vaya
rotando los
logs
de apache. Mi problema es que me gustaría que comprimira también
el
archivo
access.log.1. He mirado un poco su man y ejemplos, y he
modificado a
/etc/logrotate.d/apache2 la linea delaycompress por
nodelaycompress, de
esta
forma no se retrasa la compresión para la siguiente rotación pero
aún
así,
lo he lanzado manualmente(ya que es cron quien lo lanza):
logrotate --debug --force /etc/logrotate.d/apache2
No entiendo muy bien el porqué de que quieras hacer eso, ¿es por
falta
de espacio?
Pues cambia el numero de copias que guarda:
rotate 52
y pon alguna menos.
S2.
Gracias por contestar. No es que sea problema de espacio,
simplemente quiero
que zipee directamente el primer log rotado a .log.1. Son grandes y
quiero
zipearlos.
Con esta linea en postrotate, me soluciona el apaño:
gzip *.log.1
Saludos y gracias.
Supongo que habrás mirado las opciones:
delaycompress
nodelaycompress
delaycompress
Postpone compression of the previous log file to the
next rota‐
tion cycle. This only has effect when used in
combination with
compress. It can be used when some program cannot be
told to
close its logfile and thus might continue writing to
the previ‐
ous log file for some time.
nodelaycompress
Do not postpone compression of the previous log file
to the next
rotation cycle (this overrides the delaycompress
option).
Pero ojo, si en el logrotate de apache han puesto el delaycompress
es
por que tal vez lo necesita.
S2.
Buscando un poco encontré esto:
http://articles.slicehost.com/2010/6/30/understanding-logrotate-on-debian-part-1
delaycompress
This command can be useful if you want the archived logs to be
compressed, but not right away. With "delaycompress" active an
archived log won't be compressed until the next time the log is
rotated. This can be important when you have a program that might
still write to its old logfile for a time after a fresh one is
rotated
in. Note that "delaycompress" only works if you also have "compress"
in your config.
An example of a good time to use delaycompress would be when
logrotate
is told to restart apache with the "graceful" or "reload" directive.
Since old apache processes would not be killed until their
connections
are finished, they could potentially try to log more items to the old
file for some time after the restart. Delaying the compression
ensures
that you won't lose those extra log entries when the logs are
rotated.
Como ves, parece que es necesario y que si comprimieras el fichero
podrías perder información.
S2.