Deleting old files in Linux with find
While the Linux find command has a number of uses, the most obvious being looking for files matching full or partial names, the one often underused option is to use it to locate old files. To show all files in a directory older than 14 days:
find /var/crap_files/* -mtime +14 -print
An even more powerful option is to use the -exec switch which allows you to delete old files. To delete all files in /var/crap_files/ older than 7 days:
find /var/crap_files/* -mtime +14 -exec /bin/rm -rf {} \; 2>/dev/null 1>&2







