Welche Zeitpläne verwendet Logrotate?

Welche Zeitpläne verwendet Logrotate?

Ich arbeite an dem Programm, das eine große Protokolldatei erstellt.

Ich möchte es mit logrotate handhaben.

Dies ist eine Konfiguration, die ich eingegeben habe /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.loghat Besitzer www-data)

Befehle

sudo logrotate -vf /etc/logrotate.conf

Und

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

Drehen Sie den Stamm richtig.

Nach dem Aufruf ist es jedoch /etc/cron.hourlyleer. Das bedeutet, dass logrotate nicht stündlich aufgerufen wird.

  1. logrotateIst mir das Skript garantiert enthalten /etc/cron.daily?

  2. Überprüft das Skript die Aktualisierungshäufigkeit der Protokolldateien? Wenn ich also logrotateein Skript habe /etc/cron.dailyund für eine Protokolldatei Xdie Einstellungen /etc/logrotate.d/vornehme weekly, wird dann Xtäglich oder wöchentlich gewechselt?

  3. Kann ich einfach kopieren und einfügen /etc/cron.daily/logrotate? /etc/cron.hourly/Kann ich ausschneiden und einfügen?

  4. Soll ich 0anacrondie Datei hinzufügen /etc/cron.hourly/?

  5. Muss ich etwas anderes tun, um die stündliche Protokollierung zu aktivieren?

Antwort1

  1. NEIN.

  2. Ausman logrotate:

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

    Also ja.

  3. Nochmals aus der Manpage:

    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.
    

    Also, ja, Sie sollten das Skript verschieben. Wenn ich das cron.dailySkript in meinem System untersuche, denke ich, dass das Verschieben problemlos funktionieren sollte.

verwandte Informationen