Find and delete old files in linux

I have a few of those direc­to­ries that files tend to pile up in. I don’t need the files but I also don’t take the time to delete them. Prun­ing these old files is a good thing to keep your used disk space under con­trol as well as your san­ity. Find is a great tool to do this, its extremely flex­i­ble I rec­om­mend 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 actu­ally be older than 120 days but we are using mtime and mtime is the time when the actual con­tents 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