Delete Files Older Than One year on Linux
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?
Solution 1:
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