Find Files Based on their Age

If you want a list of all files less than 10 minutes old

> find -mmin -10

or use a + sign for more than 10 minutes old

> find -mmin  +10

For extended information about these files

> find -mmin -10 -exec ls {} -l \;

mtime is used for days, so everything modified in the last day (24 hours)

> find -mtime -1

Or last week from “now” is

> find -mtime -7

Plus, don’t forget, you can use all the other normal find parameters.

Here is an example to remove all backup files over a week old

> find -mtime +7 -name "*.tar.gz" -exec rm {} -f \;

Leave a Reply