I.T. Security and Linux Administration

Nov 17 2011   4:01PM GMT

Quick and Dirty Space Cleaner

Eric Hansen Eric Hansen Profile: 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).

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: