Delete all files in a directory older than x days

You need to have a script that deletes all files in a directory older than 7 days well Linux makes this easy:

 

Assume the directory we want to use is /local/backup

 

find /local/backup -mtime +7 -type f -exec rm -f {} \;

 

and your done.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

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