Linux
由於文件模式錯誤而忽略 /etc/logrotate.conf
我該怎麼做logrotate?當我進行 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#
您正在更改 logrotate.d 的權限。
chmod 644 /etc/logrotate.conf
你需要chown root:root /etc/logrotate.conf
然後它可以工作
我發現當 logrotate.conf 中列出的日誌文件不存在時會出現此錯誤(這可能是因為應該生成日誌的服務沒有執行)。刪除條目或刪除與其關聯的包。