Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Debian log retention, automating removal after defined period

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
postcd
Posts: 133
Joined: 2022-01-08 18:33
Has thanked: 48 times
Been thanked: 2 times

Debian log retention, automating removal after defined period

#1 Post by postcd »

Hello,

I think that it can be good idea to remove log entries/log files older like 2 months and some maybe earlier.
Possibly Debian (11, linux 5.15) already does that, but checking my logs "ls -lt /var/log" (-t sorts by time change)
I can see some older files too. I would like the /var/log contain much less entries. Currently 95.
Some are:
*.number
*.log.number
*.log.number.gz

I actually do not remember ever extracting old .gz log file for years + these numbered items seems to make rather mess than having one file.
How do you suggest to reduce the log files and get rid of lets say >2 months old entries & files?

https://wiki.debian.org/Logging does not seem to say anything to this topic

sudo journalctl|grep rotate
systemd[1]: logrotate.service: Succeeded.

systemctl status logrotate.service
loaded, inactive (seems ok)

grep . /etc/logrotate.conf
# see "man logrotate" for details
# global options do not affect preceding include directives
# rotate log files weekly
weekly
# keep 4 weeks worth of backlogs
rotate 4
# create new (empty) log files after rotating old ones
create
# use date as a suffix of the rotated file
#dateext
# uncomment this if you want your log files compressed
#compress
# packages drop log rotation information into this directory
include /etc/logrotate.d
# system-specific logs may also be configured here.
My possibly wrong and unnecessarily complicated idea on how to modify logrotate.conf is:
monthly
rotate 1
shred
dateext
compress
include /etc/logrotate.d
postrotate
find /var/log -type f -mtime +60 -delete
endscript

Post Reply