我使用的是 ubuntu 16.04,但最近我看到有人抱怨系统空间太小。我试着查找,发现这是因为这个原因,old log files
所以我发现可以通过这个来轮换旧文件
sudo /etc/cron.daily/logrotate
然后使用手动删除它漂白剂。所以我试图找出它没有自动运行的原因,并遇到了这个
并尝试在编辑器中打开 logrotate,
sudo nano /etc/cron.daily/logrotate
发现以下输出
# Clean non existent log file entries from status file
cd /var/lib/logrotate
test -e status || touch status
head -1 status > status.clean
sed 's/"//g' status | while read logfile date
do
[ -e "$logfile" ] && echo "\"$logfile\" $date"
done >> status.clean
mv status.clean status
test -x /usr/sbin/logrotate || exit 0
/usr/sbin/logrotate /etc/logrotate.conf
然后从这里得到提示打开/etc/logrotate.conf
,发现有每月指定的东西并将其改为每日。
# use the syslog group by default, since this is the owning group
# of /var/log/syslog.
su root syslog
# 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
daily
create 0664 root utmp
rotate 1
}
/var/log/btmp {
missingok
daily
create 0660 root utmp
rotate 1
}
# system-specific logs may be configured here
但仍然没有任何变化。非常感谢您的帮助