Cleaning up old files
Puppet's tidy
resource will help you clean up old or out-of-date files, reducing disk usage. For example, if you have Puppet reporting enabled, as described in the section on generating reports, you might want to regularly delete old report files.
How to do it...
Let's get started:
- Modify your
site.pp
file as follows:
node 'cookbook' { tidy { '/var/log/audit': age => '2w', recurse => true, } }
- Run Puppet:
[root@cookbook ~]# puppet agent -t Notice: /Stage[main]/Main/Node[cookbook]/File[/var/log/audit/audit.log.1]/ensure: removed
How it works...
Puppet searches the specified path for any files matching the age
parameter; in this case, 2w
(two weeks). It also searches subdirectories (recurse => true
).
Any files matching your criteria will be deleted.
There's more...
You can specify file ages in seconds, minutes, hours, days, or weeks by using a single character to specify the time unit, as follows:
- 60s
- 180m
- 24h
- 30d
- 4w
You can specify that files greater than a...