由于文件模式错误而忽略 /etc/logrotate.conf

由于文件模式错误而忽略 /etc/logrotate.conf

我怎样才能进行日志旋转?当我执行 logrotate 时,我看不到任何效果:

root@me-Latitude-E5550:/etc/logrotate.d# cd ..
root@me-Latitude-E5550:/etc# cd ..
root@me-Latitude-E5550:/# logrotate -d /etc/logrotate.conf
Ignoring /etc/logrotate.conf because of bad file mode.

Handling 0 logs
root@me-Latitude-E5550:/# chmod 644 /etc/logrotate.d/*
root@me-Latitude-E5550:/# cd /etc/logrotate.d
root@me-Latitude-E5550:/etc/logrotate.d# ls
apport       custom   pm-utils  speech-dispatcher    upstart
apt          dpkg     ppp       ufw
cups-daemon  lightdm  rsyslog   unattended-upgrades
root@me-Latitude-E5550:/etc/logrotate.d# cd ..
root@me-Latitude-E5550:/etc# cd ..
root@me-Latitude-E5550:/# logrotate -d /etc/logrotate.conf
Ignoring /etc/logrotate.conf because of bad file mode.

Handling 0 logs
root@me-Latitude-E5550:/# cd /var/log
root@me-Latitude-E5550:/var/log# ls -larth
total 34M
drwxrwxrwx  2 root root   4,0K Feb 18  2016 speech-dispatcher
drwxrwxrwx  2 root root   4,0K Mai 19  2016 upstart
drwxrwxrwx  2 root root   4,0K Jul 19  2016 fsck
-rwxrwxrwx  1 root root     31 Jul 19  2016 dmesg
-rwxrwxrwx  1 root root    57K Jul 19  2016 bootstrap.log
drwxrwxrwx  3 root root   4,0K Jul 19  2016 hp
drwxr-xr-x 14 root root   4,0K Jul 19  2016 ..
drwxrwxrwx  2 root root   4,0K Jun 14 13:17 apt
drwxrwxrwx  2 root root   4,0K Jun 14 13:20 installer
drwxrwxrwx  2 root root   4,0K Jun 19 09:50 unattended-upgrades
-rwxrwxrwx  1 root root   3,8K Jun 19 09:55 fontconfig.log
-rwxrwxrwx  1 root root    554 Jun 19 15:02 apport.log.1
drwxrwxrwx  2 root root   4,0K Jun 20 07:35 lightdm
-rwxrwxrwx  1 root root   836K Jun 20 07:35 syslog.1
-rwxrwxrwx  1 root root    32K Jun 20 14:31 faillog
-rw-------  1 root utmp    768 Jul 14 09:28 btmp
drwxrwxrwx  2 root root   4,0K Jul 14 10:38 dist-upgrade
-rwxrwxrwx  1 root root    43K Jul 14 10:45 alternatives.log
-rwxrwxrwx  1 root root   286K Jul 14 11:04 lastlog
drwxrwxrwx  2 root root   4,0K Jul 18 08:59 sysstat
-rwxrwxrwx  1 root root   1,8M Jul 18 11:13 dpkg.log
drwxrwxrwx  2 root root   4,0K Jul 18 12:19 cups
-rw-r-----  1 root adm     14K Jul 18 12:20 apport.log
-rw-r--r--  1 root root    32K Jul 18 18:38 Xorg.0.log.old
-rwxrwxrwx  1 root root   1,9K Jul 18 18:44 gpu-manager.log
-rw-r--r--  1 root root   1009 Jul 18 18:44 boot.log
drwxrwxr-x 13 root syslog 4,0K Jul 18 18:44 .
-rw-rw-r--  1 root utmp    85K Jul 18 18:45 wtmp
-rw-r--r--  1 root root    29K Jul 18 21:17 Xorg.0.log
-rwxrwxrwx  1 root root   5,7M Jul 18 21:18 kern.log
-rwxrwxrwx  1 root root   580K Jul 18 21:50 auth.log
-rwxrwxrwx  1 root root    24M Jul 18 21:54 syslog
root@me-Latitude-E5550:/var/log# logrotate -f /etc/logroate.conf
error: cannot stat /etc/logroate.conf: No such file or directory
root@me-Latitude-E5550:/var/log# logrotate -f /etc/logrotate.conf
root@me-Latitude-E5550:/var/log# ls -larth
total 34M
drwxrwxrwx  2 root root   4,0K Feb 18  2016 speech-dispatcher
drwxrwxrwx  2 root root   4,0K Mai 19  2016 upstart
drwxrwxrwx  2 root root   4,0K Jul 19  2016 fsck
-rwxrwxrwx  1 root root     31 Jul 19  2016 dmesg
-rwxrwxrwx  1 root root    57K Jul 19  2016 bootstrap.log
drwxrwxrwx  3 root root   4,0K Jul 19  2016 hp
drwxr-xr-x 14 root root   4,0K Jul 19  2016 ..
drwxrwxrwx  2 root root   4,0K Jun 14 13:17 apt
drwxrwxrwx  2 root root   4,0K Jun 14 13:20 installer
drwxrwxrwx  2 root root   4,0K Jun 19 09:50 unattended-upgrades
-rwxrwxrwx  1 root root   3,8K Jun 19 09:55 fontconfig.log
-rwxrwxrwx  1 root root    554 Jun 19 15:02 apport.log.1
drwxrwxrwx  2 root root   4,0K Jun 20 07:35 lightdm
-rwxrwxrwx  1 root root   836K Jun 20 07:35 syslog.1
-rwxrwxrwx  1 root root    32K Jun 20 14:31 faillog
-rw-------  1 root utmp    768 Jul 14 09:28 btmp
drwxrwxrwx  2 root root   4,0K Jul 14 10:38 dist-upgrade
-rwxrwxrwx  1 root root    43K Jul 14 10:45 alternatives.log
-rwxrwxrwx  1 root root   286K Jul 14 11:04 lastlog
drwxrwxrwx  2 root root   4,0K Jul 18 08:59 sysstat
-rwxrwxrwx  1 root root   1,8M Jul 18 11:13 dpkg.log
drwxrwxrwx  2 root root   4,0K Jul 18 12:19 cups
-rw-r-----  1 root adm     14K Jul 18 12:20 apport.log
-rw-r--r--  1 root root    32K Jul 18 18:38 Xorg.0.log.old
-rwxrwxrwx  1 root root   1,9K Jul 18 18:44 gpu-manager.log
-rw-r--r--  1 root root   1009 Jul 18 18:44 boot.log
drwxrwxr-x 13 root syslog 4,0K Jul 18 18:44 .
-rw-rw-r--  1 root utmp    85K Jul 18 18:45 wtmp
-rw-r--r--  1 root root    29K Jul 18 21:17 Xorg.0.log
-rwxrwxrwx  1 root root   5,7M Jul 18 21:18 kern.log
-rwxrwxrwx  1 root root   580K Jul 18 21:50 auth.log
-rwxrwxrwx  1 root root    24M Jul 18 21:55 syslog
root@me-Latitude-E5550:/var/log#

答案1

您正在更改 logrotate.d 的权限。你需要chmod 644 /etc/logrotate.conf 然后chown root:root /etc/logrotate.conf 它就可以工作

答案2

我发现当 logrotate.conf 中列出的日志文件不存在时,就会出现此错误(发生这种情况可能是因为应该生成日志的服务未运行)。删除这些条目或删除与其关联的包。

相关内容