Harsh J

Memoirs of a QWERTY Keyboard

Archive for the ‘Bash’ tag

Clearing all log files in /var/log

leave a comment

Stupid things you end up writing when you worry about filling disk spaces at 3 AM in the morning of the day right before your exams begin. The following will delete all your log files in a safe manner, by simply rewriting them to null.

cd /var/log
for file in `find .`
do
	if [ -f $file ];
	then
		cat /dev/null > $file
	fi
done

Suggest better methods if known, and thank you!

Optionally, get in there and delete those now-stagnant .gz files with the following:

find /var/log -name "*.gz" | xargs rm

P.s. So much for BS code highlight plugins printing angled brackets in HTML notations when asked to do bash.

Written by Harsh

May 19th, 2009 at 3:31 am

Posted in Blog,Linux,Personal

Tagged with , ,