Logrotate: Unterschied zwischen den Versionen
Erscheinungsbild
Keine Bearbeitungszusammenfassung |
K Textersetzung - „ “ durch „ “ |
||
| Zeile 14: | Zeile 14: | ||
# keep 4 weeks worth of backlogs | # keep 4 weeks worth of backlogs | ||
rotate 4 | rotate 4 | ||
# create new (empty) log files after rotating old ones | # create new (empty) log files after rotating old ones | ||
create | create | ||
| Zeile 26: | Zeile 26: | ||
# no packages own wtmp, or btmp -- we'll rotate them here | # no packages own wtmp, or btmp -- we'll rotate them here | ||
/var/log/wtmp { | /var/log/wtmp { | ||
missingok | |||
monthly | |||
create 0664 root utmp | |||
rotate 1 | |||
} | } | ||
/var/log/btmp { | /var/log/btmp { | ||
missingok | |||
monthly | |||
create 0660 root utmp | |||
rotate 1 | |||
} | } | ||
| Zeile 44: | Zeile 44: | ||
root@alex:/etc/logrotate.d# cat apt | root@alex:/etc/logrotate.d# cat apt | ||
/var/log/apt/term.log { | /var/log/apt/term.log { | ||
rotate 12 | |||
monthly | |||
compress | |||
missingok | |||
notifempty | |||
} | } | ||
/var/log/apt/history.log { | /var/log/apt/history.log { | ||
rotate 12 | |||
monthly | |||
compress | |||
missingok | |||
notifempty | |||
} | } | ||
Version vom 14. Juni 2026, 00:48 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.