Reicht es aus, meine Konfigurationsdatei unter /etc/logrotate.d abzulegen, um logrotieren zu können?

1129
Thierry Lam

Ich habe derzeit eine Django-App, die auf Ubuntu unter Apache läuft. Die Apache-Protokolle werden erstellt an:

/home/user/django/myproject/log/apache_access.log /home/user/django/myproject/log/apache_error.log 

Die oben genannten Protokolle wachsen derzeit sehr schnell, daher erstelle ich eine Konfigurationsdatei für Logrotate und platziere sie unter /etc/logrotate.d. Die Konfiguration heißt:, my_appes ist Pfad /etc/logrotate.d/my_app. Der Inhalt von my_appist:

/home/user/django/myproject/log/*.log{ daily missingok rotate 7 compress delaycompress notifempty create 640 root adm sharedscripts postrotate if [ -f "`. /etc/apache2/envvars ; echo $`" ]; then /etc/init.d/apache2 reload > /dev/null fi endscript } 

Logrotiert die obige Konfiguration das Apache-Protokoll?

2

1 Antwort auf die Frage

2
Zoredache

Ja, das ist alles was Sie tun müssen.

Wenn logrotate ausgeführt wird, enthält die Hauptkonfigurationsdatei alle Konfigurationsbereiche im Ordner logrotate.d.

Sehen:

/etc/logrotate.conf ... # packages drop log rotation information into this directory include /etc/logrotate.d 
Natürlich sollten Sie sicherstellen, dass die Include-Zeile in Ihrer Installation NICHT auskommentiert ist uSlackr vor 12 Jahren 0