Posted by: Eric Hansen
I’ve been noticing my /var/log getting pretty full over the past week. I’ve deleted some old logs that were made from logwatch, but wanted a better (read: lazier) solution. Now, if you don’t care about the contents of the log files, then this is awesome. However, generally I wouldn’t try this on a production environment unless you know the logs won’t be needed. Here’s the one-liner I use:
for i in `find . -type f`; do echo '' > $i; done
This is assuming you’re in the “/var/log/” directory (or where ever your logs are stored). A simple routine to just clear out the contents of every log. This brought my /var directory from 92% usage to 22% usage (which, as a side note, has an allocated 4.6 GB of space).