find . -mtime +X -exec rm {} \;
#example - remove files older than 90 days
find . -mtime +90 -exec rm {} \;
Linux Delete Files Older Than X Days
Remove files in the current directory that are older than X days. This can make a handy cron job when certain applications store files to a disk cache but door a poor job of removing them.
Snippet Viewed 2085 times.
Share your Linux code snippets:
- Get some recognition & link back to your site.
Related Articles