Thursday 29 December 2011

How to find the large log files older than one year to delete on unix

How to find the large log files older than one year to delete on unix?

To find the one year old large log files, execute the below command

find . -name '*.log' -size +200k -mtime +360 -print

where find is the command
. is for the current directory ( if you want to check on /var/log then specify the directory here)
'*.log' is to check for the log files
-size  is to check for the size of the log files. I gave 200k
-mtime is to check for the time +360 for one year old files
-print is to show the files on the screen.