Thursday, August 25, 2011

Finding and deleting old log files

Occassionally you need to clean up some disk space. The quickest and easiest thing to do is often to look for log files that have been rolled by some other process.

For Example:
find . -name *.log.5 -exec /bin/rm '{}' \;
Of course, you need to understand the naming convention of your logs.  Here's a quick example of finding and removing files with a date appended to the original log name.  This command will remove all the log files for the first 9 days of August 2011.

find . -name *.log.2011-08-0* -exec /bin/rm '{}' \;