Deleting /var/log
is probably a bad idea, but deleting the individual logfiles should be OK.
On my laptop, with a smallish SSD disk, I set up /var/log
(and /tmp
and /var/tmp
) as tmpfs
mount points, by adding the following lines to /etc/fstab
:
temp /tmp tmpfs rw,mode=1777 0 0
vartmp /var/tmp tmpfs rw,mode=1777 0 0
varlog /var/log tmpfs rw,mode=1777 0 0
This means that nothing in those directories survives a reboot. As far as I can tell, this setup works just fine. Of course, I lose the ability to look at old logs to diagnose any problems that might occur, but I consider that a fair tradeoff for the reduced disk usage.
The only problem I've had is that some programs (most notably APT) want to write their logs into subdirectories of /var/log
and aren't smart enough to create those directories if they don't exist. Adding the line mkdir /var/log/apt
into /etc/rc.local
fixed that particular problem for me; depending on just what software you have installed, you may need to create some other directories too.
(Another possibility would be to create a simple tar
archive containing just the directories, and to untar it into /var/log
at startup to create all the needed directories and set their permissions all at once.)