
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.log
hat 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.hourly
leer. Das bedeutet, dass logrotate nicht stündlich aufgerufen wird.
logrotate
Ist mir das Skript garantiert enthalten/etc/cron.daily
?Überprüft das Skript die Aktualisierungshäufigkeit der Protokolldateien? Wenn ich also
logrotate
ein Skript habe/etc/cron.daily
und für eine ProtokolldateiX
die Einstellungen/etc/logrotate.d/
vornehmeweekly
, wird dannX
täglich oder wöchentlich gewechselt?Kann ich einfach kopieren und einfügen
/etc/cron.daily/logrotate
?/etc/cron.hourly/
Kann ich ausschneiden und einfügen?Soll ich
0anacron
die Datei hinzufügen/etc/cron.hourly/
?Muss ich etwas anderes tun, um die stündliche Protokollierung zu aktivieren?
Antwort1
NEIN.
Aus
man logrotate
:Each configuration file can set global options (local definitions override global ones, and later definitions override earlier ones)
Also ja.
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.daily
Skript in meinem System untersuche, denke ich, dass das Verschieben problemlos funktionieren sollte.