Outils pour utilisateurs

Outils du site


tech:notes_logrotate

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
tech:notes_logrotate [2025/03/24 15:06] – créée - modification externe 127.0.0.1tech:notes_logrotate [2026/06/07 19:12] (Version actuelle) – modification externe 127.0.0.1
Ligne 1: Ligne 1:
 +<!DOCTYPE markdown>
 +{{tag>Brouillon}}
 +
 +# Notes logrotate
 +
 +Voir : 
 +* https://access.redhat.com/documentation/fr-fr/red_hat_enterprise_linux/7/html/system_administrators_guide/s1-basic_configuration_of_rsyslog#s2-log_rotation
 +
 +Voir aussi :
 +* [tmpfiles.d (SystemD)](https://www.freedesktop.org/software/systemd/man/tmpfiles.d.html)
 +
 +`/etc/cron.daily/logrotate`
 +~~~bash
 +#!/bin/sh
 +
 +/usr/sbin/logrotate /etc/logrotate.conf >/dev/null 2>&1
 +EXITVALUE=$?
 +if [ $EXITVALUE != 0 ]; then
 +    /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
 +fi
 +exit 0
 +~~~
 +
 +## Exemple de conf
 +
 +~~~
 +/opt/atom/apache-tomcat-*/logs/catalina.out
 +{
 + copytruncate
 + weekly
 + rotate 52
 + compress
 + missingok
 + size 5M
 +}
 +
 +/var/log/cups/*_log {
 +    missingok
 +    notifempty
 +    sharedscripts
 +}
 +
 +/var/log/dracut.log {
 +    missingok
 +    notifempty
 +    size 30k
 +    yearly
 +    create 0600 root root
 +}
 +
 +/var/log/clamav/freshclam.log {
 +        missingok
 +        notifempty
 +        create 644 clam clam
 +
 +
 +/var/log/httpd/*log {
 +    missingok
 +    notifempty
 +    sharedscripts
 +    delaycompress
 +    postrotate
 +        /sbin/service httpd reload > /dev/null 2>/dev/null || true
 +    endscript
 +}
 +
 +/var/log/numad.log {
 +    compress
 +    copytruncate
 +    maxage 60
 +    missingok
 +    rotate 5
 +    size 1M
 +
 +
 +# Rotate OCS Inventory NG agent logs daily, only if not empty
 +# Save 7 days old logs under compressed mode
 +/var/log/ocsinventory-agent/*.log {
 +        daily
 +        rotate 7
 +        compress
 +        notifempty
 +        missingok
 +}
 +
 +
 +/var/account/pacct {
 +#prerotate loses accounting records, let's no
 +#   prerotate
 +#       /usr/sbin/accton
 +#   endscript
 +    compress
 +    delaycompress
 +    notifempty
 +    daily
 +    rotate 31
 +    create 0600 root root
 +    postrotate
 +       /usr/sbin/accton /var/account/pacct
 +    endscript
 +
 +
 +/var/log/sssd/*.log {
 +    weekly
 +    missingok
 +    notifempty
 +    sharedscripts
 +    rotate 2
 +    compress
 +    postrotate
 +        /bin/kill -HUP `cat /var/run/sssd.pid  2>/dev/null`  2> /dev/null || true
 +    endscript
 +
 +
 +/var/log/cron
 +/var/log/maillog
 +/var/log/messages
 +/var/log/secure
 +/var/log/spooler
 +{
 +    sharedscripts
 +    postrotate
 +        /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
 +    endscript
 +}
 +
 +/var/log/yum.log {
 +    missingok
 +    notifempty
 +    size 30k
 +    yearly
 +    create 0600 root root
 +}
 +~~~
 +
 +## Test
 +
 +~~~bash
 +logrotate -df /etc/logrotate.d/plop
 +~~~
 +
 +
  

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki