Logrotate: Unterschied zwischen den Versionen
Erscheinungsbild
Weiterleitung nach Https://wiki.foxtom.de/index.php/LPIC102/108.2 Systemprotokollierung#logrotate erstellt Markierungen: Neue Weiterleitung Visuelle Bearbeitung |
Keine Bearbeitungszusammenfassung |
||
| (3 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
# | ==logrotate== | ||
''logrotate'' rotiert und komprimiert Logdateien, damit diese nicht unkontrolliert anwachsen. | |||
* Die Konfig-Dateien sind: ''/etc/logrotate.conf'' und ''/etc/logrotate.d'' | |||
* Nach Ablauf eines Intervalls verschiebt er die Datei, indem er die Dateiendung ''.1'' hinten anstellt, beim nächsten Intervall wird die zuvor verschobene Datei wieder umbenannt und diesmal auch noch komprimiert, sodass hinten ein ''.2.gz'' steht. | |||
* Wie viele alte Logfiles und das Intervall kann man in der ''logrotate.conf'' ändern | |||
So könnte eine ''logrotate.conf'' aussehen: | |||
<syntaxhighlight lang="bash" highlight="1" line copy> | |||
</syntaxhighlight> | |||
# see "man logrotate" for details | |||
# rotate log files weekly | |||
weekly | |||
# keep 4 weeks worth of backlogs | |||
rotate 4 | |||
# create new (empty) log files after rotating old ones | |||
create | |||
# uncomment this if you want your log files compressed | |||
#compress | |||
# packages drop log rotation information into this directory | |||
include /etc/logrotate.d | |||
# no packages own wtmp, or btmp -- we'll rotate them here | |||
/var/log/wtmp { | |||
missingok | |||
monthly | |||
create 0664 root utmp | |||
rotate 1 | |||
} | |||
/var/log/btmp { | |||
missingok | |||
monthly | |||
create 0660 root utmp | |||
rotate 1 | |||
} | |||
Dateien in logrotate.d sind nach dem gleichen Muster aufgebaut | |||
<syntaxhighlight lang="bash" highlight="1" line copy> | |||
</syntaxhighlight> | |||
root@alex:/etc/logrotate.d# cat apt | |||
/var/log/apt/term.log { | |||
rotate 12 | |||
monthly | |||
compress | |||
missingok | |||
notifempty | |||
} | |||
/var/log/apt/history.log { | |||
rotate 12 | |||
monthly | |||
compress | |||
missingok | |||
notifempty | |||
} | |||
''logrotate'' sollte am besten täglich ausgeführt werden. Hierfür eignet sich ''[[cron]]''. | |||
== Links == | |||
# [[LPIC102/108.2 Systemprotokollierung#logrotate]] | |||
Aktuelle Version vom 5. März 2026, 13:49 Uhr
logrotate
logrotate rotiert und komprimiert Logdateien, damit diese nicht unkontrolliert anwachsen.
- Die Konfig-Dateien sind: /etc/logrotate.conf und /etc/logrotate.d
- Nach Ablauf eines Intervalls verschiebt er die Datei, indem er die Dateiendung .1 hinten anstellt, beim nächsten Intervall wird die zuvor verschobene Datei wieder umbenannt und diesmal auch noch komprimiert, sodass hinten ein .2.gz steht.
- Wie viele alte Logfiles und das Intervall kann man in der logrotate.conf ändern
So könnte eine logrotate.conf aussehen:
# see "man logrotate" for details
# rotate log files weekly
weekly
# keep 4 weeks worth of backlogs
rotate 4
# create new (empty) log files after rotating old ones
create
# uncomment this if you want your log files compressed
#compress
# packages drop log rotation information into this directory
include /etc/logrotate.d
# no packages own wtmp, or btmp -- we'll rotate them here
/var/log/wtmp {
missingok
monthly
create 0664 root utmp
rotate 1
}
/var/log/btmp {
missingok
monthly
create 0660 root utmp
rotate 1
}
Dateien in logrotate.d sind nach dem gleichen Muster aufgebaut
root@alex:/etc/logrotate.d# cat apt
/var/log/apt/term.log {
rotate 12
monthly
compress
missingok
notifempty
}
/var/log/apt/history.log {
rotate 12
monthly
compress
missingok
notifempty
}
logrotate sollte am besten täglich ausgeführt werden. Hierfür eignet sich cron.