PDA

Bekijk Volledige Versie : Apache / awstats logrotate probleem



martinvandebelt
30/12/09, 15:33
Hey,


Ik heb een probleempje met de combinatie Apache / awstats / logrotate waar ik al een paar weken tegen aan loop te schoppen.

Awstats wordt elke dag geüpdate. Logrotate wordt elke week gedraait om op te ruimen in de log files. Alleen het probleem onstaat wanneer deze logrotate gedraait heeft. De log-files zijn daarna altijd leeg totdat ik apache handmatig restart. Op de één of andere manier worden ze daarom gelocked.

Heb ook al naar permissies gekeken, maar deze staan allemaal goed. (permissies en owner zijn het zelfde na de logrotate als na een apache restart).

Config: Debian 5 64 bit, Apache geinstalleerd mbv apt-get, awstats geinstalleerd volgens de handleiding.

/etc/logrotate.d/apache2:




/var/log/apache2/*.log {
weekly
missingok
rotate 52
compress
delaycompress
notifempty
create 777 root adm
sharedscripts
prerotate
/usr/lib/cgi-bin/awstats.pl -config=awstats.conf -update endscript
postrotate
if [ -f "`. /etc/apache2/envvars ; echo ${APACHE_PID_FILE:-/var/run/apache2.pid}`" ]; then
/etc/init.d/apache2 restart > /dev/null
fi
endscript
}


Let niet op die smerige create 777, dit was om de permissies te testen. Nieuwe log-files worden dus met 777 rechten aangemaakt. Dus probleem zit daar niet.
Heb eerder ook /etc/init.d/apache2 reload ook al eens veranderd in /etc/init.d/apache2 restart. Dit hielp ook niks.


Kan wel een crontabje maken die apache handmatig restart na het runnen van logrotate, maar dat vind ik eigenlijk een smerige oplossing.


Iemand die bekend is met dit probleem? Google geeft niet veel resultaten, of ik zoek verkeerd..

martinvandebelt
02/01/10, 15:30
Niemand die dit ooit meegemaakt heeft?

Pur
02/01/10, 15:49
On even a moderately busy server, the quantity of information stored in the log files is very large. The access log file typically grows 1 MB or more per 10,000 requests. It will consequently be necessary to periodically rotate the log files by moving or deleting the existing logs. This cannot be done while the server is running, because Apache will continue writing to the old log file as long as it holds the file open. Instead, the server must be restarted after the log files are moved or deleted so that it will open new log files.

By using a graceful restart, the server can be instructed to open new log files without losing any existing or pending connections from clients. However, in order to accomplish this, the server must continue to write to the old log files while it finishes serving old requests. It is therefore necessary to wait for some time after the restart before doing any processing on the log files. A typical scenario that simply rotates the logs and compresses the old logs to save space is:


Oftewel gewoon normaal gedrag van Apache.

Maar je hoeft geen logrotate te doen als je ook awstats gebruikt. Deze kan de logfile zelf truncaten waardoor je het hele probleem niet hebt.

martinvandebelt
02/01/10, 22:00
Oftewel gewoon normaal gedrag van Apache.

Thanks, ik denk dat het dat inderdaad is. Alleen erg vreemd dat het niet out-of-the-box goed werkt .. Is allemaal gebaseerd op standaard configuratie.



Maar je hoeft geen logrotate te doen als je ook awstats gebruikt. Deze kan de logfile zelf truncaten waardoor je het hele probleem niet hebt.

Daar had ik ook al aan zitten denken ja. Denk dat dat het makkelijkst is.