Thi*_*vel 1 linux logging rsyslog
rsyslog 配置中有一个选项可以设置创建的日志文件的权限和所有权。
$fileOwner sv
if $programname contains 'my_process' then /var/log/my_process.log
Run Code Online (Sandbox Code Playgroud)
如果日志文件 ( /var/log/my_process.log) 不存在,则将创建该文件,其所有者为“sv”用户。手动的
但这也将更改所有即将出现的文件的设置。
有没有办法只设置特定日志文件的权限?
我找到了一种行之有效的方法。配置完成后,将变量重置回默认值。
$fileOwner sv
if $programname contains 'my_process' then /var/log/my_process.log
$fileOwner root
Run Code Online (Sandbox Code Playgroud)