Find and delete old files in linux

I have a few of those directories that files tend to pile up in. I don’t need the files but I also don’t take the time to delete them. Pruning these old files is a good thing to keep your used disk space under control as well as your sanity. Find is a great tool to do this, its extremely flexible I recommend you read the man page next time your bored.

find /directory/with/old/files -mtime +120 -exec rm {} \;

Here we use find to find files that are older than 120 days. The “older” here being the key word. So they might actually be older than 120 days but we are using mtime and mtime is the time when the actual contents of a file was last modified.

3 Comments

Leave a Reply

Your email is never shared.Required fields are marked *

To submit your comment, click the image below where it asks you to...
Clickcha - The One-Click Captcha