Logrotate不旋转

Logrotate不旋转

我已经为 logrotate 设置了新的配置,但就是无法让它工作。

这是我的日志轮换:

/home/deployer/abc/shared/log/*.log {
  daily
  missingok
  rotate 30
  compress
  delaycompress
  size 5M
  copytruncate
}

以下是我尝试过的:

删除的状态文件:

deployer@qapp01:~/abc/current/log$ cat /var/lib/logrotate/status 
logrotate state -- version 2

使用调试模式运行 logrotate

deployer@qapp01:~/abc/current/log$ /usr/sbin/logrotate -d /etc/logrotate.conf
reading config file /etc/logrotate.conf
including /etc/logrotate.d
reading config file apt
reading config file aptitude
reading config file dpkg
reading config file fail2ban
reading config file monit
reading config file mysql-server
reading config file newrelic-sysmond
reading config file nginx
reading config file ppp
reading config file abc
reading config file rsyslog
reading config file ufw
reading config file unattended-upgrades
reading config file upstart

Handling 19 logs

rotating pattern: /var/log/apt/term.log  monthly (12 rotations)
empty log files are not rotated, old logs are removed
switching euid to 0 and egid to 104
error: error switching euid to 0 and egid to 104: Operation not permitted

rotating pattern: /var/log/apt/history.log  monthly (12 rotations)
empty log files are not rotated, old logs are removed
switching euid to 0 and egid to 104
error: error switching euid to 0 and egid to 104: Operation not permitted

rotating pattern: /var/log/aptitude  monthly (6 rotations)
empty log files are not rotated, old logs are removed
switching euid to 0 and egid to 104
error: error switching euid to 0 and egid to 104: Operation not permitted

rotating pattern: /var/log/dpkg.log  monthly (12 rotations)
empty log files are not rotated, old logs are removed
switching euid to 0 and egid to 104
error: error switching euid to 0 and egid to 104: Operation not permitted

rotating pattern: /var/log/alternatives.log  monthly (12 rotations)
empty log files are not rotated, old logs are removed
switching euid to 0 and egid to 104
error: error switching euid to 0 and egid to 104: Operation not permitted

rotating pattern: /var/log/fail2ban.log  weekly (4 rotations)
empty log files are rotated, old logs are removed
switching euid to 0 and egid to 104
error: error switching euid to 0 and egid to 104: Operation not permitted

rotating pattern: /var/log/monit.log  weekly (4 rotations)
empty log files are not rotated, only log files >= 1048576 bytes are rotated, old logs are removed
switching euid to 0 and egid to 104
error: error switching euid to 0 and egid to 104: Operation not permitted

rotating pattern: /var/log/mysql.log /var/log/mysql/mysql.log /var/log/mysql/mariadb-slow.log  after 1 days (7 rotations)
empty log files are rotated, old logs are removed
switching euid to 0 and egid to 104
error: error switching euid to 0 and egid to 104: Operation not permitted

rotating pattern: /var/log/newrelic/nrsysmond.log  after 1 days (7 rotations)
empty log files are not rotated, old logs are removed
switching euid to 0 and egid to 104
error: error switching euid to 0 and egid to 104: Operation not permitted

rotating pattern: /var/log/nginx/*.log  after 1 days (14 rotations)
empty log files are not rotated, old logs are removed
No logs found. Rotation not needed.

rotating pattern: /var/log/ppp-connect-errors  weekly (4 rotations)
empty log files are not rotated, old logs are removed
switching euid to 0 and egid to 104
error: error switching euid to 0 and egid to 104: Operation not permitted

rotating pattern: /home/deployer/abc/shared/log/*.log  5242880 bytes (30 rotations)
empty log files are rotated, old logs are removed
switching euid to 0 and egid to 104
error: error switching euid to 0 and egid to 104: Operation not permitted

rotating pattern: /var/log/syslog
 after 1 days (7 rotations)
empty log files are not rotated, old logs are removed
switching euid to 0 and egid to 104
error: error switching euid to 0 and egid to 104: Operation not permitted

rotating pattern: /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
 weekly (4 rotations)
empty log files are not rotated, old logs are removed
switching euid to 0 and egid to 104
error: error switching euid to 0 and egid to 104: Operation not permitted

rotating pattern: /var/log/ufw.log
 weekly (4 rotations)
empty log files are not rotated, old logs are removed
switching euid to 0 and egid to 104
error: error switching euid to 0 and egid to 104: Operation not permitted

rotating pattern: /var/log/unattended-upgrades/unattended-upgrades.log 
/var/log/unattended-upgrades/unattended-upgrades-shutdown.log
 monthly (6 rotations)
empty log files are not rotated, old logs are removed
switching euid to 0 and egid to 104
error: error switching euid to 0 and egid to 104: Operation not permitted

rotating pattern: /var/log/upstart/*.log  after 1 days (7 rotations)
empty log files are not rotated, old logs are removed
switching euid to 0 and egid to 104
error: error switching euid to 0 and egid to 104: Operation not permitted

rotating pattern: /var/log/wtmp  monthly (1 rotations)
empty log files are rotated, old logs are removed
switching euid to 0 and egid to 104
error: error switching euid to 0 and egid to 104: Operation not permitted

rotating pattern: /var/log/btmp  monthly (1 rotations)
empty log files are rotated, old logs are removed
switching euid to 0 and egid to 104
error: error switching euid to 0 and egid to 104: Operation not permitted

尝试使用 sudo 运行它

deployer@qapp01:~/abc/current/log$ sudo /usr/sbin/logrotate -d /etc/logrotate.conf
[sudo] password for deployer: 
reading config file /etc/logrotate.conf
including /etc/logrotate.d
reading config file apt
reading config file aptitude
reading config file dpkg
reading config file fail2ban
reading config file monit
reading config file mysql-server
reading config file newrelic-sysmond
reading config file nginx
reading config file ppp
reading config file abc
reading config file rsyslog
reading config file ufw
reading config file unattended-upgrades
reading config file upstart

Handling 19 logs

rotating pattern: /var/log/apt/term.log  monthly (12 rotations)
empty log files are not rotated, old logs are removed
switching euid to 0 and egid to 104
considering log /var/log/apt/term.log
  log does not need rotating
switching euid to 0 and egid to 0

rotating pattern: /var/log/apt/history.log  monthly (12 rotations)
empty log files are not rotated, old logs are removed
switching euid to 0 and egid to 104
considering log /var/log/apt/history.log
  log does not need rotating
switching euid to 0 and egid to 0

rotating pattern: /var/log/aptitude  monthly (6 rotations)
empty log files are not rotated, old logs are removed
switching euid to 0 and egid to 104
considering log /var/log/aptitude
  log /var/log/aptitude does not exist -- skipping
switching euid to 0 and egid to 0

rotating pattern: /var/log/dpkg.log  monthly (12 rotations)
empty log files are not rotated, old logs are removed
switching euid to 0 and egid to 104
considering log /var/log/dpkg.log
  log does not need rotating
switching euid to 0 and egid to 0

rotating pattern: /var/log/alternatives.log  monthly (12 rotations)
empty log files are not rotated, old logs are removed
switching euid to 0 and egid to 104
considering log /var/log/alternatives.log
  log does not need rotating
switching euid to 0 and egid to 0

rotating pattern: /var/log/fail2ban.log  weekly (4 rotations)
empty log files are rotated, old logs are removed
switching euid to 0 and egid to 104
considering log /var/log/fail2ban.log
  log does not need rotating
switching euid to 0 and egid to 0

rotating pattern: /var/log/monit.log  weekly (4 rotations)
empty log files are not rotated, only log files >= 1048576 bytes are rotated, old logs are removed
switching euid to 0 and egid to 104
considering log /var/log/monit.log
  log does not need rotating
switching euid to 0 and egid to 0

rotating pattern: /var/log/mysql.log /var/log/mysql/mysql.log /var/log/mysql/mariadb-slow.log  after 1 days (7 rotations)
empty log files are rotated, old logs are removed
switching euid to 0 and egid to 104
considering log /var/log/mysql.log
  log does not need rotating
considering log /var/log/mysql/mysql.log
  log does not need rotating
considering log /var/log/mysql/mariadb-slow.log
  log /var/log/mysql/mariadb-slow.log does not exist -- skipping
not running postrotate script, since no logs were rotated
switching euid to 0 and egid to 0

rotating pattern: /var/log/newrelic/nrsysmond.log  after 1 days (7 rotations)
empty log files are not rotated, old logs are removed
switching euid to 0 and egid to 104
considering log /var/log/newrelic/nrsysmond.log
  log does not need rotating
switching euid to 0 and egid to 0

rotating pattern: /var/log/nginx/*.log  after 1 days (14 rotations)
empty log files are not rotated, old logs are removed
switching euid to 0 and egid to 104
considering log /var/log/nginx/access.log
  log does not need rotating
considering log /var/log/nginx/error.log
  log does not need rotating
not running prerotate script, since no logs will be rotated
not running postrotate script, since no logs were rotated
switching euid to 0 and egid to 0

rotating pattern: /var/log/ppp-connect-errors  weekly (4 rotations)
empty log files are not rotated, old logs are removed
switching euid to 0 and egid to 104
considering log /var/log/ppp-connect-errors
  log /var/log/ppp-connect-errors does not exist -- skipping
switching euid to 0 and egid to 0

rotating pattern: /home/deployer/abc/shared/log/*.log  5242880 bytes (30 rotations)
empty log files are rotated, old logs are removed
switching euid to 0 and egid to 104
considering log /home/deployer/abc/shared/log/newrelic_agent.log
  log does not need rotating
considering log /home/deployer/abc/shared/log/nginx.access.log
  log needs rotating
considering log /home/deployer/abc/shared/log/nginx.error.log
  log does not need rotating
considering log /home/deployer/abc/shared/log/production.delayed_job.log
  log does not need rotating
considering log /home/deployer/abc/shared/log/production.log
  log needs rotating
considering log /home/deployer/abc/shared/log/production.searchd.log
  log does not need rotating
considering log /home/deployer/abc/shared/log/production.searchd.query.log
  log does not need rotating
considering log /home/deployer/abc/shared/log/puma_access.log
  log does not need rotating
considering log /home/deployer/abc/shared/log/puma_error.log
  log does not need rotating
considering log /home/deployer/abc/shared/log/rake_ean_geocode.log
  log does not need rotating
considering log /home/deployer/abc/shared/log/rake_ean_min_rate.log
  log does not need rotating
considering log /home/deployer/abc/shared/log/rake_ean_update_spots.log
  log does not need rotating
rotating log /home/deployer/abc/shared/log/nginx.access.log, log->rotateCount is 30
dateext suffix '-20160618'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
previous log /home/deployer/abc/shared/log/nginx.access.log.1 does not exist
renaming /home/deployer/abc/shared/log/nginx.access.log.30.gz to /home/deployer/abc/shared/log/nginx.access.log.31.gz (rotatecount 30, logstart 1, i 30), 
renaming /home/deployer/abc/shared/log/nginx.access.log.29.gz to /home/deployer/abc/shared/log/nginx.access.log.30.gz (rotatecount 30, logstart 1, i 29), 
renaming /home/deployer/abc/shared/log/nginx.access.log.28.gz to /home/deployer/abc/shared/log/nginx.access.log.29.gz (rotatecount 30, logstart 1, i 28), 
renaming /home/deployer/abc/shared/log/nginx.access.log.27.gz to /home/deployer/abc/shared/log/nginx.access.log.28.gz (rotatecount 30, logstart 1, i 27), 
renaming /home/deployer/abc/shared/log/nginx.access.log.26.gz to /home/deployer/abc/shared/log/nginx.access.log.27.gz (rotatecount 30, logstart 1, i 26), 
renaming /home/deployer/abc/shared/log/nginx.access.log.25.gz to /home/deployer/abc/shared/log/nginx.access.log.26.gz (rotatecount 30, logstart 1, i 25), 
renaming /home/deployer/abc/shared/log/nginx.access.log.24.gz to /home/deployer/abc/shared/log/nginx.access.log.25.gz (rotatecount 30, logstart 1, i 24), 
renaming /home/deployer/abc/shared/log/nginx.access.log.23.gz to /home/deployer/abc/shared/log/nginx.access.log.24.gz (rotatecount 30, logstart 1, i 23), 
renaming /home/deployer/abc/shared/log/nginx.access.log.22.gz to /home/deployer/abc/shared/log/nginx.access.log.23.gz (rotatecount 30, logstart 1, i 22), 
renaming /home/deployer/abc/shared/log/nginx.access.log.21.gz to /home/deployer/abc/shared/log/nginx.access.log.22.gz (rotatecount 30, logstart 1, i 21), 
renaming /home/deployer/abc/shared/log/nginx.access.log.20.gz to /home/deployer/abc/shared/log/nginx.access.log.21.gz (rotatecount 30, logstart 1, i 20), 
renaming /home/deployer/abc/shared/log/nginx.access.log.19.gz to /home/deployer/abc/shared/log/nginx.access.log.20.gz (rotatecount 30, logstart 1, i 19), 
renaming /home/deployer/abc/shared/log/nginx.access.log.18.gz to /home/deployer/abc/shared/log/nginx.access.log.19.gz (rotatecount 30, logstart 1, i 18), 
renaming /home/deployer/abc/shared/log/nginx.access.log.17.gz to /home/deployer/abc/shared/log/nginx.access.log.18.gz (rotatecount 30, logstart 1, i 17), 
renaming /home/deployer/abc/shared/log/nginx.access.log.16.gz to /home/deployer/abc/shared/log/nginx.access.log.17.gz (rotatecount 30, logstart 1, i 16), 
renaming /home/deployer/abc/shared/log/nginx.access.log.15.gz to /home/deployer/abc/shared/log/nginx.access.log.16.gz (rotatecount 30, logstart 1, i 15), 
renaming /home/deployer/abc/shared/log/nginx.access.log.14.gz to /home/deployer/abc/shared/log/nginx.access.log.15.gz (rotatecount 30, logstart 1, i 14), 
renaming /home/deployer/abc/shared/log/nginx.access.log.13.gz to /home/deployer/abc/shared/log/nginx.access.log.14.gz (rotatecount 30, logstart 1, i 13), 
renaming /home/deployer/abc/shared/log/nginx.access.log.12.gz to /home/deployer/abc/shared/log/nginx.access.log.13.gz (rotatecount 30, logstart 1, i 12), 
renaming /home/deployer/abc/shared/log/nginx.access.log.11.gz to /home/deployer/abc/shared/log/nginx.access.log.12.gz (rotatecount 30, logstart 1, i 11), 
renaming /home/deployer/abc/shared/log/nginx.access.log.10.gz to /home/deployer/abc/shared/log/nginx.access.log.11.gz (rotatecount 30, logstart 1, i 10), 
renaming /home/deployer/abc/shared/log/nginx.access.log.9.gz to /home/deployer/abc/shared/log/nginx.access.log.10.gz (rotatecount 30, logstart 1, i 9), 
renaming /home/deployer/abc/shared/log/nginx.access.log.8.gz to /home/deployer/abc/shared/log/nginx.access.log.9.gz (rotatecount 30, logstart 1, i 8), 
renaming /home/deployer/abc/shared/log/nginx.access.log.7.gz to /home/deployer/abc/shared/log/nginx.access.log.8.gz (rotatecount 30, logstart 1, i 7), 
renaming /home/deployer/abc/shared/log/nginx.access.log.6.gz to /home/deployer/abc/shared/log/nginx.access.log.7.gz (rotatecount 30, logstart 1, i 6), 
renaming /home/deployer/abc/shared/log/nginx.access.log.5.gz to /home/deployer/abc/shared/log/nginx.access.log.6.gz (rotatecount 30, logstart 1, i 5), 
renaming /home/deployer/abc/shared/log/nginx.access.log.4.gz to /home/deployer/abc/shared/log/nginx.access.log.5.gz (rotatecount 30, logstart 1, i 4), 
renaming /home/deployer/abc/shared/log/nginx.access.log.3.gz to /home/deployer/abc/shared/log/nginx.access.log.4.gz (rotatecount 30, logstart 1, i 3), 
renaming /home/deployer/abc/shared/log/nginx.access.log.2.gz to /home/deployer/abc/shared/log/nginx.access.log.3.gz (rotatecount 30, logstart 1, i 2), 
renaming /home/deployer/abc/shared/log/nginx.access.log.1.gz to /home/deployer/abc/shared/log/nginx.access.log.2.gz (rotatecount 30, logstart 1, i 1), 
renaming /home/deployer/abc/shared/log/nginx.access.log.0.gz to /home/deployer/abc/shared/log/nginx.access.log.1.gz (rotatecount 30, logstart 1, i 0), 
copying /home/deployer/abc/shared/log/nginx.access.log to /home/deployer/abc/shared/log/nginx.access.log.1
truncating /home/deployer/abc/shared/log/nginx.access.log
removing old log /home/deployer/abc/shared/log/nginx.access.log.31.gz
error: error opening /home/deployer/abc/shared/log/nginx.access.log.31.gz: No such file or directory
rotating log /home/deployer/abc/shared/log/production.log, log->rotateCount is 30
dateext suffix '-20160618'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
previous log /home/deployer/abc/shared/log/production.log.1 does not exist
renaming /home/deployer/abc/shared/log/production.log.30.gz to /home/deployer/abc/shared/log/production.log.31.gz (rotatecount 30, logstart 1, i 30), 
renaming /home/deployer/abc/shared/log/production.log.29.gz to /home/deployer/abc/shared/log/production.log.30.gz (rotatecount 30, logstart 1, i 29), 
renaming /home/deployer/abc/shared/log/production.log.28.gz to /home/deployer/abc/shared/log/production.log.29.gz (rotatecount 30, logstart 1, i 28), 
renaming /home/deployer/abc/shared/log/production.log.27.gz to /home/deployer/abc/shared/log/production.log.28.gz (rotatecount 30, logstart 1, i 27), 
renaming /home/deployer/abc/shared/log/production.log.26.gz to /home/deployer/abc/shared/log/production.log.27.gz (rotatecount 30, logstart 1, i 26), 
renaming /home/deployer/abc/shared/log/production.log.25.gz to /home/deployer/abc/shared/log/production.log.26.gz (rotatecount 30, logstart 1, i 25), 
renaming /home/deployer/abc/shared/log/production.log.24.gz to /home/deployer/abc/shared/log/production.log.25.gz (rotatecount 30, logstart 1, i 24), 
renaming /home/deployer/abc/shared/log/production.log.23.gz to /home/deployer/abc/shared/log/production.log.24.gz (rotatecount 30, logstart 1, i 23), 
renaming /home/deployer/abc/shared/log/production.log.22.gz to /home/deployer/abc/shared/log/production.log.23.gz (rotatecount 30, logstart 1, i 22), 
renaming /home/deployer/abc/shared/log/production.log.21.gz to /home/deployer/abc/shared/log/production.log.22.gz (rotatecount 30, logstart 1, i 21), 
renaming /home/deployer/abc/shared/log/production.log.20.gz to /home/deployer/abc/shared/log/production.log.21.gz (rotatecount 30, logstart 1, i 20), 
renaming /home/deployer/abc/shared/log/production.log.19.gz to /home/deployer/abc/shared/log/production.log.20.gz (rotatecount 30, logstart 1, i 19), 
renaming /home/deployer/abc/shared/log/production.log.18.gz to /home/deployer/abc/shared/log/production.log.19.gz (rotatecount 30, logstart 1, i 18), 
renaming /home/deployer/abc/shared/log/production.log.17.gz to /home/deployer/abc/shared/log/production.log.18.gz (rotatecount 30, logstart 1, i 17), 
renaming /home/deployer/abc/shared/log/production.log.16.gz to /home/deployer/abc/shared/log/production.log.17.gz (rotatecount 30, logstart 1, i 16), 
renaming /home/deployer/abc/shared/log/production.log.15.gz to /home/deployer/abc/shared/log/production.log.16.gz (rotatecount 30, logstart 1, i 15), 
renaming /home/deployer/abc/shared/log/production.log.14.gz to /home/deployer/abc/shared/log/production.log.15.gz (rotatecount 30, logstart 1, i 14), 
renaming /home/deployer/abc/shared/log/production.log.13.gz to /home/deployer/abc/shared/log/production.log.14.gz (rotatecount 30, logstart 1, i 13), 
renaming /home/deployer/abc/shared/log/production.log.12.gz to /home/deployer/abc/shared/log/production.log.13.gz (rotatecount 30, logstart 1, i 12), 
renaming /home/deployer/abc/shared/log/production.log.11.gz to /home/deployer/abc/shared/log/production.log.12.gz (rotatecount 30, logstart 1, i 11), 
renaming /home/deployer/abc/shared/log/production.log.10.gz to /home/deployer/abc/shared/log/production.log.11.gz (rotatecount 30, logstart 1, i 10), 
renaming /home/deployer/abc/shared/log/production.log.9.gz to /home/deployer/abc/shared/log/production.log.10.gz (rotatecount 30, logstart 1, i 9), 
renaming /home/deployer/abc/shared/log/production.log.8.gz to /home/deployer/abc/shared/log/production.log.9.gz (rotatecount 30, logstart 1, i 8), 
renaming /home/deployer/abc/shared/log/production.log.7.gz to /home/deployer/abc/shared/log/production.log.8.gz (rotatecount 30, logstart 1, i 7), 
renaming /home/deployer/abc/shared/log/production.log.6.gz to /home/deployer/abc/shared/log/production.log.7.gz (rotatecount 30, logstart 1, i 6), 
renaming /home/deployer/abc/shared/log/production.log.5.gz to /home/deployer/abc/shared/log/production.log.6.gz (rotatecount 30, logstart 1, i 5), 
renaming /home/deployer/abc/shared/log/production.log.4.gz to /home/deployer/abc/shared/log/production.log.5.gz (rotatecount 30, logstart 1, i 4), 
renaming /home/deployer/abc/shared/log/production.log.3.gz to /home/deployer/abc/shared/log/production.log.4.gz (rotatecount 30, logstart 1, i 3), 
renaming /home/deployer/abc/shared/log/production.log.2.gz to /home/deployer/abc/shared/log/production.log.3.gz (rotatecount 30, logstart 1, i 2), 
renaming /home/deployer/abc/shared/log/production.log.1.gz to /home/deployer/abc/shared/log/production.log.2.gz (rotatecount 30, logstart 1, i 1), 
renaming /home/deployer/abc/shared/log/production.log.0.gz to /home/deployer/abc/shared/log/production.log.1.gz (rotatecount 30, logstart 1, i 0), 
copying /home/deployer/abc/shared/log/production.log to /home/deployer/abc/shared/log/production.log.1
truncating /home/deployer/abc/shared/log/production.log
removing old log /home/deployer/abc/shared/log/production.log.31.gz
error: error opening /home/deployer/abc/shared/log/production.log.31.gz: No such file or directory
switching euid to 0 and egid to 0

rotating pattern: /var/log/syslog
 after 1 days (7 rotations)
empty log files are not rotated, old logs are removed
switching euid to 0 and egid to 104
considering log /var/log/syslog
  log does not need rotating
switching euid to 0 and egid to 0

rotating pattern: /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
 weekly (4 rotations)
empty log files are not rotated, old logs are removed
switching euid to 0 and egid to 104
considering log /var/log/mail.info
  log /var/log/mail.info does not exist -- skipping
considering log /var/log/mail.warn
  log /var/log/mail.warn does not exist -- skipping
considering log /var/log/mail.err
  log /var/log/mail.err does not exist -- skipping
considering log /var/log/mail.log
  log /var/log/mail.log does not exist -- skipping
considering log /var/log/daemon.log
  log /var/log/daemon.log does not exist -- skipping
considering log /var/log/kern.log
  log does not need rotating
considering log /var/log/auth.log
  log does not need rotating
considering log /var/log/user.log
  log /var/log/user.log does not exist -- skipping
considering log /var/log/lpr.log
  log /var/log/lpr.log does not exist -- skipping
considering log /var/log/cron.log
  log /var/log/cron.log does not exist -- skipping
considering log /var/log/debug
  log /var/log/debug does not exist -- skipping
considering log /var/log/messages
  log /var/log/messages does not exist -- skipping
not running postrotate script, since no logs were rotated
switching euid to 0 and egid to 0

rotating pattern: /var/log/ufw.log
 weekly (4 rotations)
empty log files are not rotated, old logs are removed
switching euid to 0 and egid to 104
considering log /var/log/ufw.log
  log /var/log/ufw.log does not exist -- skipping
not running postrotate script, since no logs were rotated
switching euid to 0 and egid to 0

rotating pattern: /var/log/unattended-upgrades/unattended-upgrades.log 
/var/log/unattended-upgrades/unattended-upgrades-shutdown.log
 monthly (6 rotations)
empty log files are not rotated, old logs are removed
switching euid to 0 and egid to 104
considering log /var/log/unattended-upgrades/unattended-upgrades.log
  log /var/log/unattended-upgrades/unattended-upgrades.log does not exist -- skipping
considering log /var/log/unattended-upgrades/unattended-upgrades-shutdown.log
  log does not need rotating
switching euid to 0 and egid to 0

rotating pattern: /var/log/upstart/*.log  after 1 days (7 rotations)
empty log files are not rotated, old logs are removed
switching euid to 0 and egid to 104
considering log /var/log/upstart/acpid.log
  log does not need rotating
considering log /var/log/upstart/nginx.log
  log does not need rotating
considering log /var/log/upstart/rsyslog.log
  log does not need rotating
considering log /var/log/upstart/systemd-logind.log
  log does not need rotating
switching euid to 0 and egid to 0

rotating pattern: /var/log/wtmp  monthly (1 rotations)
empty log files are rotated, old logs are removed
switching euid to 0 and egid to 104
considering log /var/log/wtmp
  log does not need rotating
switching euid to 0 and egid to 0

rotating pattern: /var/log/btmp  monthly (1 rotations)
empty log files are rotated, old logs are removed
switching euid to 0 and egid to 104
considering log /var/log/btmp
  log does not need rotating
switching euid to 0 and egid to 0

但是我的应用程序日志仍然没有轮换:

deployer@qapp01:~/abc/current/log$ ll
total 1227256
drwxrwxr-x  2 deployer deployer       4096 Jun 18 15:53 ./
drwxrwxr-x 11 deployer deployer       4096 Jun 18 11:18 ../
-rw-rw-r--  1 deployer deployer     574462 Jun 18 15:54 newrelic_agent.log
-rw-r--r--  1 root     root       25550727 Jun 18 15:55 nginx.access.log
-rw-r--r--  1 root     root              0 Jun 18 00:13 nginx.error.log
-rw-rw-r--  1 deployer deployer       4455 Jun 18 15:44 production.delayed_job.log
-rw-rw-r--  1 deployer deployer 1230525588 Jun 18 15:55 production.log
-rw-------  1 deployer deployer       6798 Jun 18 11:35 production.searchd.log
-rw-------  1 deployer deployer       6302 Jun 18 15:44 production.searchd.query.log
-rw-rw-r--  1 deployer deployer        120 Jun 18 00:30 puma_access.log
-rw-rw-r--  1 deployer deployer         48 Jun 18 00:30 puma_error.log
-rw-rw-r--  1 deployer deployer          0 Jun 17 12:16 rake_ean_geocode.log
-rw-rw-r--  1 deployer deployer          0 Jun 17 12:16 rake_ean_min_rate.log
-rw-rw-r--  1 deployer deployer          0 Jun 17 12:16 rake_ean_update_spots.log

我已经毫无头绪了,甚至在谷歌上搜索了各种解决方案但都无济于事。

答案1

您在配置中为这些日志文件指定了 和size。我的理解是,这会导致任何基于时间的轮换被忽略(请参阅此处的类似问题 -dailysize例如这个)。

基于此,我目前期望被旋转的唯一文件是production.lognginx.access.log。使用调试运行的输出sudo显示logrotate确实会旋转这些文件。

请记住,运行时-d logrotate不会进行任何更改。如果您想要了解有关正在发生的事情的更多信息以及进行更改,请使用-v

请注意(一般来说)logrotate需要以 身份运行。请注意,通过 运行时root不会收到有关 的警告。switching euidsudo

答案2

以下是我让它工作的方法:

  1. 根据 Paul Haldane 上述的回答,确保它是sizedaily
  2. 确保中的文件/etc/logrotate.d/abcroot-所有sudo chown root:root /etc/logrotate.d/abc
  3. 确保文件/etc/logrotate.d/abc至少具有 644 权限 - sudo chmod 644 /etc/logrotate.d/abc
  4. 为了使 logrotate 具有正确的工作权限,请将其添加到/etc/logrotate.d/abc具有正确用户权限的 logrotate 文件中。例如,我的日志文件归 拥有deployer:deployer,那么我将 添加su deployer deployer/etc/logrotate.d/abc

相关内容