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 :
- Switch to the directory where you want to remove the files
- 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 …