M BUZZ CRAZE NEWS
// general

Delete Files Older Than One year on Linux

By Emma Martinez

By the time, many files are still on my system and I don't need them anymore, so how to delete all files that are one year old at least?

1 Answer

You can do it with this command

find /path/to/files* -mtime +365 -exec rm {} \;

Some explain

/path/to/files* is the path to the files.

-mtime is used to specify the number of days old that the file is. +365 will find files older than 365 days which is one year

-exec allows you to pass in a command such as rm.


Edit Thanks to @Oli note --> you can do it by:

find /path/to/files* -mtime +365 -delete
4

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy