this very easy linux command can be use to remove files older than certain days. Its very useful when you’re doing clean-up of old files.

Step by step :

  1. Switch to the directory where you want to remove the files
  2. issue the following command : find -mtime +60 -exec rm {} \;

Explanation :

  • find : command to find all files
  • -mtime +60 : switch to find files older than 60 days
  • -exec rm {} \; : remove all the files that match the above switch

alternative : find /path/to/folder/* -mtime +60 -exec rm{} \;

the alternative not recommended for long path as you will have “Argument to long” error.

Hope it helps …

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.