我正在为某些Web应用编写自己的logrotate配置:
/home/me/public_html/logs/*.log {
daily
missingok
rotate 15
compress
delaycompress
notifempty
create 0660 me www-data
nosharedscripts
}
但是对于这些文件运行logrotate会导致:
$ sudo logrotate -d -v *.log
Ignoring logfile1.log because of bad file mode.
Ignoring logfile2.log because of bad file mode.
Ignoring otherlogfile.log because of bad file mode.
Handling 0 logs
$ ls -l
-rw-rw---- 1 me www-data 893584 Jan 27 16:01 logfile1.log
-rw-rw---- 1 me www-data 395011 Jan 27 16:01 logfile2.log
-rw-rw---- 1 me www-data 4949115 Jan 27 16:01 otherlogfile.log
这是否与目录中实际日志文件的文件权限或使用 create 0660 me www-data
指定的权限有关?
如果我将文件权限更改为 -rw-r-----
并将 create
行更改为
create 0640 me www-data
我明白了
$ sudo logrotate -d -v *.log
Ignoring logfile1.log because the file owner is wrong (should be root).
Ignoring logfile2.log because the file owner is wrong (should be root).
Ignoring otherlogfile.log because the file owner is wrong (should be root).
Handling 0 logs
我的系统是Debian Testing/Jessie。
sudo chmod [numbers] [files]
的实际解决方案。现在我必须继续寻找。 - MS Berendschmod
命令吗? - white_geckochmod
:( 如果我找到了,我会添加的。 - MS Berendschown root /home/me/public_html/logs/logfile1.log
和chmod 600 /home/me/public_html/logs/logfile1.log
,按照我之前的示例。如果你能尝试一下,就可以将其添加到答案中。 - white_gecko