Removing old files in UNIX

To remove files older than 90 days from the current directory and all sub directories try this:

find . -name "*"  -mtime +90 -exec rm -rf {} \;

If you only want to list how much space each file or folder is using using try:

find . -name "*"  -mtime +90 -exec du -sh {} \;

If you want to search for large log file, try

find . -name "*.log" -exec du -sh {} \;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s