Previous post talked about the linux command to purge old log files. Here is the way of doing the same thing, but with chef
cookbooks/housekeep/recipes/default.rb
# we need cron for scheduler
package cron do
action :install
end
include_recipe "housekeep::clear_log"
cookbooks/housekeep/recipes/clear_log.rb
cron "housekeep application log files" do
user "housekeeper"
# mailto "your@example.com"
# 00:01 every night
hour "0"
minute "1"
# clean up logs older than 30 days
command "/find ~/log/application-*.log.tar.gz -mtime +30 -exec rm {} \;"
end
Snippet available in gist:https://gist.github.com/798157