I take back my suggestion.
LogRotate is not built to handle many little log files with different names. I
found out the hard way - I tried to make it work :(
The script by vagn will do the trick.
Another suggestion: put a variable in the line "tail -n +2” in place of the “2”
for how-many-files-to-keep+1 -- “2” only keeps one file. Other folks may want
to keep more.
On Jan 31, 2013, at 10:23 PM, Dan White wrote:
> How about logrotate ?
>
> On Jan 30, 2013, at 11:53 AM, Andrew Sinclair wrote:
>
>> Great solution. Simple, effective. Thanks.
>>
>> On Thursday, 21 July 2011 14:50:32 UTC+1, vagn wrote:
>> On 07/21/2011 08:52 AM, vagn scott wrote:
>> > Thinking about this some more, if you need the reports for dashboard
>> > to work,
>> > then any cleanup script should leave the latest report from any server,
>> > so that, even if the server has not checked in for a while it won't
>> > disappear.
>> >
>> > Thanks for the question. Clearly I need to revisit this.
>> >
>> So, here is a script that ought to do the job. Not heavily tested yet.
>> Please let me know if you have problems with it. --vagn
>>
>> #! /bin/sh
>> # puppet-reports-stalker
>> # vagn scott, 21-jul-2011
>>
>> days="+7" # more than 7 days old
>>
>> for d in `find /var/lib/puppet/reports -mindepth 1 -maxdepth 1 -type d`
>> do
>> find $d -type f -name \*.yaml -mtime $days |
>> sort -r |
>> tail -n +2 |
>> xargs -n50 /bin/rm -f
>> done
>>
>> exit 0
>>
>>
>> And the updated class.
>>
>> class puppet::clean_reports {
>>
>> file { '/usr/local/bin/puppet-reports-stalker':
>> source =>
>> 'puppet:///modules/puppet/puppet-reports-stalker',
>> before => Cron[ 'puppet clean reports' ],
>> mode => 755,
>> owner => root,
>> group => root,
>> }
>>
>> cron { 'puppet clean reports':
>> command => '/usr/local/bin/puppet-reports-stalker',
>> user => root,
>> hour => 21,
>> minute => 22,
>> weekday => 0,
>> }
>> }
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Puppet Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/puppet-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/puppet-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.