logrotate 表示旋转日志/重新创建日志文件时权限被拒绝
我是 Linux 机器上的 logrotate 新手...这是我在应用程序的 logrotate.d 文件中设置的内容:
/var/log/myapp.log {
daily
missingok
create 0660 root utmp
rotate 1
}
我直接使用 chmod 为运行相关应用程序的帐户在 myapp.log 文件上设置所有者权限来自 bash shell。
当应用程序第一次运行时,一切都很好。它记录得很好,一切都很好。但是当日志轮换时,它会删除日志文件,然后尝试重新创建日志文件,并给出权限被拒绝的错误:
/bin/bash: /var/log/myapp.log: Permission denied
我知道我在 logrotate 配置文件或 chmod 或其他东西上做错了......可以有人指出我正确的方向并帮助我解决问题吗?
I'm new to logrotate on linux machines... here's what I have set up in my app's logrotate.d file:
/var/log/myapp.log {
daily
missingok
create 0660 root utmp
rotate 1
}
I set owner permissions on the myapp.log file for the account that runs the app in question, using chmod, directly from the bash shell.
when the app first runs, everything is fine. It logs just fine and it's all good. But when the log gets rotated, it deletes the log file and then tries to recreate the log file and it gives a permission denied error:
/bin/bash: /var/log/myapp.log: Permission denied
I know I'm doing something wrong with either the logrotate config file or chmod or something... can someone point me in the right direction and help me fix the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
...所以除非“运行相关应用程序的帐户”是
root
,否则配置选项是错误的,因为这要求
logrotate
创建一个新的myapp.log
(在将原始myapp.log
旋转为myapp.log.0
后),拥有权限0660
用户root
和组utmp
。将这些替换为您的应用程序所需的属性应该可以解决问题。...so unless "the account that runs the app in question" is
root
, the config optionis wrong, because that is asking
logrotate
to create a newmyapp.log
(after it has rotated the originalmyapp.log
tomyapp.log.0
) with permissions0660
owned by userroot
and grouputmp
. Replacing these with the attributes required by your app should solve the problem.