Delete Files Older Than x Days

Delete Files Older Than x Days

find /path/to/directory/ -mindepth 1 -mtime +5 -delete

-mindepth 1 means delete everything except for the folder itself.
-mtime is in days
-delete needs to be at the end of the line.

Tip: Replace -delete with -depth -print to test without deleting.

Source

Leave a Reply

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