/var/log/syslog 不旋转

Jus*_*tin 6 syslog logrotate

我们的日志文件/var/log/syslog似乎没有旋转,即使 logrotate 配置/etc/logrotate.d/rsyslog存在:

/var/log/syslog
{
    rotate 7
    daily
    missingok
    notifempty
    delaycompress
    compress
    postrotate
        reload rsyslog >/dev/null 2>&1 || true
    endscript
}

/var/log/mail.info
/var/log/mail.warn
/var/log/mail.err
/var/log/mail.log
/var/log/daemon.log
/var/log/kern.log
/var/log/auth.log
/var/log/user.log
/var/log/lpr.log
/var/log/cron.log
/var/log/debug
/var/log/messages
{
    rotate 4
    weekly
    missingok
    notifempty
    compress
    delaycompress
    sharedscripts
    postrotate
        reload rsyslog >/dev/null 2>&1 || true
    endscript
}
Run Code Online (Sandbox Code Playgroud)

看,syslog日志文件是 600M 没有旧文件或压缩。

-rw-r-----  1 syslog   adm    600M Nov  9 20:30 syslog
Run Code Online (Sandbox Code Playgroud)

Jus*_*tin 13

我发现了问题,不知何故su从 中删除了指令/etc/logrotate.conf,因此需要添加:

# use the syslog group by default, since this is the owning group
# of /var/log/syslog.
su root syslog
Run Code Online (Sandbox Code Playgroud)