尝试使用logrotate时,在logrotate.d中为特定定义运行日志轮换脚本时出现以下错误
error: error creating state file /var/lib/logrotate/status: Permission denied
/var/lib/logrotate$ ls -lah
total 12K
drwxr-xr-x 2 root root 4.0K 2012-05-11 06:25 .
drwxr-xr-x 43 root root 4.0K 2012-05-18 08:07 ..
-rw-r--r-- 1 root root 911 2012-05-25 06:25 status
我还没有接触过这条路径,所以我想知道为什么它会默认创建一个错误...
发布于 2012-05-26 05:40:19
你确定你是以超级用户身份运行这个命令...??;)如果是这样,请检查系统上是否有AppArmour -如果有,检查它的配置或卸载它(Ubuntu的情况)。
发布于 2012-10-21 02:36:30
DO NOT chmod
default status file to 666 (不要将默认状态文件设置为666)。如果你chmod
它,系统上的每个用户都能够使用logrotate
作为攻击载体。
只需使用选项[-s|--state file]
为您的用户定义一个(私有)状态文件(假设您试图以普通用户身份运行它)。
发布于 2017-07-12 22:33:10
在crontab中有这样一行:
* * * * * root logrotate -s /var/run/logrotate.status /etc/logrotate.conf
即使它是以root用户身份运行的,我也无法摆脱“错误:创建状态文件/var/run/logrotate/status时出错:权限被拒绝”错误。
所以我只是使用了一个不同的目录:
* * * * * root /usr/sbin/logrotate -s /var/log/logrotate.status -v /etc/logrotate.conf >/tmp/logrotate.out 2>&1
使用了https://serverfault.com/questions/762587/daily-logrotate-error-creating-unique-temp-file-permission-denied中的调试思想,但对其进行了更改,使输出文件不会无限增长,这将是具有讽刺意味的。
在这种情况下,详细模式没有提供任何额外的信息,顺便说一句,它正在读取哪个配置文件和相同的错误消息。但最好将输出放在该文件中,而不是放在/var/mailspool中。
https://stackoverflow.com/questions/10761495
复制相似问题