14 February 2012

Delete Files Older Than x Days

Applies to FreeBSD and Linux.


find /mnt/backup1 -maxdepth 2 -name '*.gz' -mtime +7 -exec rm {} \;

This will find and remove files that are 7 days old. It will search 2 folders deep from /mnt/backup1. It will not search folder1 or folder2. The single quotes around the name search string are required at least on FreeBSD.

No comments:

Post a Comment