log-files – Linux:如何对日志轮换创建的新创建的日志强制执行特定权限?

log-files – Linux:如何对日志轮换创建的新创建的日志强制执行特定权限?,第1张

概述我注意到在/ var / log中创建的邮件日志正由root(用户和组)创建并拥有. 我写了一个监控日志的Nagios检查,为了让Nagios用户可以访问它,我给了另一个组读取权限,即: chmod o+r /var/log/maillog 现在当我想到它时,这只是一个日志文件,当日志文件将被填充时,日志旋转机制将重命名该文件并打开一个新文件,但新的maillog文件将没有我允许的读取权限. 所以 我注意到在/ var / log中创建的邮件日志正由root(用户和组)创建并拥有.
我写了一个监控日志的Nagios检查,为了让Nagios用户可以访问它,我给了另一个组读取权限,即:
chmod o+r /var/log/maillog

现在当我想到它时,这只是一个日志文件,当日志文件将被填充时,日志旋转机制将重命名该文件并打开一个新文件,但新的maillog文件将没有我允许的读取权限.

所以我的问题是,如何确保日志轮换机制将创建具有Nagios用户权限的所有新mailllog文件?

提前致谢

解决方法 logrotate有create选项:
create mode owner group

Immediately after rotation (before the postrotate script is run) the log file is created (with the same name as the log
file just rotated). mode specifIEs the mode for the log file in octal (the same as chmod(2)),owner specifIEs the user
name who will own the log file,and group specifIEs the group the log file will belong to. Any of the log file attributes
may be omitted,in which case those attributes for the new file will use the same values as the original log file for the
omitted attributes. This option can be Disabled using the nocreate option.

更多信息与男人logrotate.

像这样使用它:

/var/log/maillog {....        create 664 user group....}

在/etc/logrotate.conf中或/etc/logrotate.d中的单独文件中检查是否已有任何其他文件覆盖此文件.如何配置取决于您的 *** 作系统(例如,在Ubuntu上,这是在rsyslog配置中处理的).

总结

以上是内存溢出为你收集整理的log-files – Linux:如何对日志轮换创建的新创建的日志强制执行特定权限?全部内容,希望文章能够帮你解决log-files – Linux:如何对日志轮换创建的新创建的日志强制执行特定权限?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/1044072.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存