Linux – Delete files which are older than N days

One day i found that the Puppet master is running out of space and then i realize that there is a lot of run reports in YAML format located @ /var/lib/puppet/reports. I want to delete the old reports for releasing the disk space.

So i move to the /var/lib/puppet/reports directory and execute the following line to recursively remove any .yaml which is older than 14 days.

find $d -type f -name \*.yaml -mtime "+14" -exec rm -f {} \;

 

A few years ago i had a post about a housekeeping shell script which is quite similar to the above approach.

Done =)

Reference: Google Groups – Purge puppet’s reports

Advertisement

One thought on “Linux – Delete files which are older than N days”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.