Fichier access log1 qui grossit...si je ne redémarre pas le serveur NGINX! [ a priori résolu]

What type of hardware are you using: Other(?)
What YunoHost version are you running: 12.09.1
How are you able to access your server: The webadmin
Are you in a special context or did you perform specific tweaking on your YunoHost instance ?: non

Describe your issue

Mon serveur est un mini-ordinateur en celeron J4125. J’ai effectué la migration vers yunohost 12.09.1 il y a quelques jours. J’ai remarqué en suivant les logs que les fichiers de logs du serveur NGINX n’évoluaient plus comme avant avec la version 11 de Yunohost, avec en particulier le fichier access log1 où tous les logs de la semaine s’implémentent alors que le fichier access log est bien crée à minuit au bout d’un jour mais reste vide. Le fichier access log1 n’étant jamais compressé le jour suivant sa création je crains que l’accumulation de logs soit très vite un problème pour le serveur.
Ce que j’ai essayé:

  1. régénerer la configuration de base du serveur NGINX de yunohost avec la commande suivante:
    yunohost tools regen-conf nginx -f
  2. seule la méthode manuelle de redémarrer le serveur NGINX permet de faire basculer les nouveaux logs du fichier access log1 au fichier access log. et d’enclencher la compression du fichier access log 1 le jour suivant.

Share relevant logs or error messages

Une hypothèse est qu’une tâche cron ne s’effectue pas.

Fichier etc/cron.daily/logrotate:

#!/bin/sh

# skip in favour of systemd timer
if [ -d /run/systemd/system ]; then
    exit 0
fi

# this cronjob persists removals (but not purges)
if [ ! -x /usr/sbin/logrotate ]; then
    exit 0
fi

/usr/sbin/logrotate /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
    /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit $EXITVALUE

Fichier etc/logrotate.d/nginx:

/var/log/nginx/*.log {
	daily
	missingok
	rotate 14
	compress
	delaycompress
	notifempty
	create 0640 www-data adm
	sharedscripts
	prerotate
		if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
			run-parts /etc/logrotate.d/httpd-prerotate; \
		fi \
	endscript
	postrotate
		invoke-rc.d nginx rotate >/dev/null 2>&1
	endscript
}

Bonjour,
Après recherches j’ai modifié le fichier etc/logrotate.d/nginx comme ceci:

/var/log/nginx/*.log {
	daily
	missingok
	rotate 14
	compress
	delaycompress
	notifempty
	create 0640 www-data adm
	sharedscripts
	prerotate
		if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
			run-parts /etc/logrotate.d/httpd-prerotate; \
		fi \
	endscript
	postrotate
		invoke-rc.d nginx rotate >/dev/null 2>&1
		
	endscript
	postrotate
		[ -f /run/nginx.pid ] && kill -USR1 `cat /run/nginx.pid`
	endscript
}


j’ai simplement rajouté (bourrinage? je ne sais pas coder :o )

postrotate
		[ -f /run/nginx.pid ] && kill -USR1 `cat /run/nginx.pid`
	endscript

et ça a l’air de fonctionner. (j’avais repéré que les processus de nginx devaient être redémarrés après la rotation des logs)

Quelqu’un pour confirmer que cela n’a pas d’impact autre sur le serveur?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.