今天第一次尝试写logrotate的配置文件,重启logrotate服务时出现如下错误:logrotate.service: Failed with result 'exit-code'.
如果我删除我的文件并重新启动logrotate.service,一切都正常
这是我的 logrotate.conf 配置文件
# see "man logrotate" for details
# rotate log files weekly
weekly
# keep 4 weeks worth of backlogs
rotate 4
# create new (empty) log files after rotating old ones
create
# use date as a suffix of the rotated file
#dateext
# uncomment this if you want your log files compressed
#compress
# packages drop log rotation information into this directory
include /etc/logrotate.d
# system-specific logs may be also be configured here.
这是我的自定义配置文件
/var/www/webd/logs/clean.log
{
rotate 12
monthly
missingok
notifempty
compress
}
这个文件有什么问题?
谢谢,
蒂埃里
答案1
感谢您的回答@Tilman Schmidt,我意识到我的问题来自于对日志文件的访问权限问题
févr. 24 08:34:30 logrotate[23728]: error: skipping "/var/www/webd/logs/clean.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.
通过在我的配置文件中添加子句su webd webd
并重新启动 logrotate 服务,一切都恢复正常
/var/www/webd/logs/clean.log
{
rotate 12
monthly
missingok
notifempty
compress
su webd webd
}
感谢您的帮助 :)
他们的人