No description
Find a file
2025-10-23 19:01:35 +00:00
README.md Ajouter README.md 2025-10-23 19:01:35 +00:00

Configuration de LogRotate pour apache2

Fichier /etc/logrotate.d/apache2

/var/log/apache2/*.log {
    daily
    missingok
    rotate 120
    compress
    delaycompress
    notifempty
    create 640 root adm
    sharedscripts
    prerotate
        if [ -d /etc/logrotate.d/httpd-prerotate ]; then
            run-parts /etc/logrotate.d/httpd-prerotate
        fi
    endscript
    postrotate
        if pgrep -f ^/usr/sbin/apache2 > /dev/null; then
            invoke-rc.d apache2 reload 2>&1 | logger -t apache2.logrotate
        fi
    endscript
}

Pour le restart :

# systemctl restart logrotate

Et dans la crontab :

 1 * * * zcat -f /var/log/apache2/access* | /usr/local/bin/goaccess - -o /var/www/html/goaccess/index.html --log-format=COMBINED --keep-last=120

Je garde 120 jours ...

La taille :

# du -sh /var/log/apache2/
47M	/var/log/apache2/