¿Qué horarios logrotate?

¿Qué horarios logrotate?

Estoy trabajando en el programa que crea un archivo de registro grande.

Quiero manejarlo con logrotate.

Esta es una configuración que puse en /etc/logrotate.d/:

/var/log/myproject.log  {
 hourly
 maxsize 1
 rotate 6
 missingok
 notifempty
 compress
 nocreate
 copytruncate
 su www-data www-data 
}

( /var/log/myproject.logtiene dueño www-data)

Comandos

sudo logrotate -vf /etc/logrotate.conf

y

sudo logrotate -vf /etc/logrotate.d/myproject

gire el tronco correctamente.

Sin embargo, después de llamarlos /etc/cron.hourlyqueda vacío. Lo que significa que logrotate no se llama cada hora.

  1. ¿Tengo la garantía de tener logrotatescript /etc/cron.daily?

  2. ¿El script verifica la frecuencia de actualización de los archivos de registro? Es decir, si tengo logrotateun script /etc/cron.dailyy para algún archivo de registro Xen la configuración /etc/logrotate.d/que configuré weekly, ¿se Xrotará diaria o semanalmente?

  3. ¿Puedo simplemente copiar y pegar /etc/cron.daily/logrotateen /etc/cron.hourly/? ¿Puedo cortar y pegar?

  4. ¿Debo agregar 0anacronun archivo /etc/cron.hourly/?

  5. ¿Debo hacer algo más para habilitar el registro por horas?

Respuesta1

  1. No.

  2. Deman logrotate:

    Each  configuration  file  can  set  global  options (local definitions
    override global ones, and later definitions override earlier ones)
    

    Entonces sí.

  3. Nuevamente, desde la página de manual:

    hourly Log files are rotated every hour. Note that usually logrotate is
           configured  to  be  run  by  cron daily. You have to change this
           configuration and run logrotate hourly  to  be  able  to  really
           rotate logs hourly.
    

    Entonces, sí, deberías mover el guión. Al inspeccionar el cron.dailyscript en mi sistema, creo que moverlo debería funcionar bien.

información relacionada