Skip to content

Instantly share code, notes, and snippets.

@gswallow
Last active August 29, 2015 14:10
Show Gist options
  • Save gswallow/ce11d2b6d448a79699fe to your computer and use it in GitHub Desktop.
Save gswallow/ce11d2b6d448a79699fe to your computer and use it in GitHub Desktop.
mongodb log rotation with chef
logrotate_app node['mongodb']['instance_name'] do
frequency 'daily'
cookbook 'logrotate'
options ['compress', 'dateext', 'missingok', 'notifempty', 'copytruncate']
path node['mongodb']['config']['logpath']
sharedscripts true
postrotate %Q!kill -USR1 `cat #{['mongodb']['config']['pidfilepath']} 2> /dev/null` 2> /dev/null || true\nfind `dirname #{node['mongodb']['config']['logpath']}` -type f -regex ".*\\.\\(log.[0-9].*-[0-9].*\\)" -exec rm {} \\; 2> /dev/null || true!
rotate 30
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment