我正在为一些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。
发布于 2015-01-30 20:35:48
好吧,愚蠢的情况。必须对配置文件而不是日志文件执行logrotate命令。
$ sudo logrotate -d -v /etc/logrotate.d/my-app日志文件的父目录不是完全可写的(------rw-),也不是任何非root组(---rw----)都能写的,这一点似乎很重要。否则,您将看到:
error: skipping "/home/me/public_html/logs/logfile1.log" because parent
directory has insecure permissions (It's world writable or writable by
group which is not "root") Set "su" directive in config file to tell
logrotate which user/group should be used for rotation.https://stackoverflow.com/questions/28233917
复制相似问题