Search & Delete using find command


I have configure log rotate on my apache access logs. It make zip file on end of day. Day by day its increasing n I don’t have space to keep all logs.

I want to delete 7 days old zip files from that folder.

# cd /usr/local/apache2/logs/

# find . -name “*.zip” -mtime +7| xargs rm -fv

Explanation of command.

find . — means find in present directory

-name “*.zip” — find files which ends with .zip extension

-mtime +7 —means search files before last 7 days

| xargs rm -fv — this means it will get the output of find command & process it using rm command

This entry was posted in Linux_Tips_n_Tricks. Bookmark the permalink.

Leave a Reply

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

You are commenting using your 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