我写了一个监控日志的Nagios检查,为了让Nagios用户可以访问它,我给了另一个组读取权限,即:
chmod o+r /var/log/maillog
现在当我想到它时,这只是一个日志文件,当日志文件将被填充时,日志旋转机制将重命名该文件并打开一个新文件,但新的maillog文件将没有我允许的读取权限.
所以我的问题是,如何确保日志轮换机制将创建具有Nagios用户权限的所有新mailllog文件?
提前致谢
解决方法
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
@H_404_26@
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配置中处理的).