有点奇怪的是,在我的 /var/log 目录中,许多文件(例如 syslog、auth.log)似乎都有较旧的日志文件(按 [0-9] 轮换,有些像 dpkg.log 甚至现在轮换到 12),但重要的 wtmp 日志文件只有 wtmp.1 轮换,它存储了相当新的日志(我已经使用笔记本电脑好几年了,所以在正常情况下它应该有更多的 wtmp 日志)。
是否因为某些系统设置阻止我的笔记本电脑存储更多 wtmp 日志?(我不记得我更改了这个默认设置。)
谢谢。
答案1
您只需编辑该/etc/logrotate.conf
文件:
sudo gedit /etc/logrotate.conf
我的默认样子是这样的:
# 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
}
# system-specific logs may be configured here
您所要做的就是改变:
/var/log/wtmp {
missingok
monthly
create 0664 root utmp
rotate 1 <------ change this value to 12 to keep log files for 12 months
}
经过
/var/log/wtmp {
missingok
monthly
create 0664 root utmp
rotate 12
}
保存日志文件12个月。