【发布时间】:2017-02-01 13:55:51
【问题描述】:
我正在使用以下配方来执行log rotation:
bash 'adding_logrotate_for_consul' do
code <<-EOH
echo "" >> /etc/logrotate.conf
echo "/tmp/output.log {" >> /etc/logrotate.conf
echo -e "\tsize 20M" >> /etc/logrotate.conf
echo -e "\tcreate 700 root root" >> /etc/logrotate.conf
echo -e "\trotate 3" >> /etc/logrotate.conf
echo "}" >> /etc/logrotate.conf
EOH
end
上面的代码运行得很好,它在/etc/logrotate.conf中添加了以下条目
/tmp/output.log {
size 20M
create 700 root root
rotate 3
}
但是,使用chef添加上述条目后,我每次都必须在节点上手动运行以下命令:
logrotate -s /var/log/logstatus /etc/logrotate.conf
如何在 chef recipe 中包含上述命令,以便在文件大小达到 20M 后使用 chef recipe 执行日志轮换??
【问题讨论】:
-
把这个包含在书架上['log_rotation'] { 'file_maxbytes' => 104857600, 'num_to_keep' => 10 } ...你的问题应该解决了。
标签: cron chef-infra chef-recipe logrotate log-rotation