Just had the message:
Low disk space.. 2 GB left
Judging by a posted message on ubuntu.org forums, I found that I have a .log file in /var/log
at 22 GB in size! My root is an 82 GB partition and Disk Analyser shows the offender to be in log. The system root was installed circa 8 months ago, so clearly this is not a good thing in creating a 22 GB log on an 82 GB root partition.
Is it safe to delete the log file or please advise on the correct safe procedure to cleanse it without messing up my system. I presume it may be ok, but would like some other opinions before I do the task of delete.
It is generally safe to delete log files. The only disadvantage associated with doing so is that you may not be able to examine the log, if you're troubleshooting some other problem later. Since new logs are automatically generated, even this disadvantage is short-lived.
Most logs are deleted automatically (after being rotated by compression and renaming, and kept a while in that archived format). If you have a log that's expanded faster than Ubuntu is deleting it, it's unlikely that you'll experience any problems from deleting it manually.
However, if you have a log file that's 22 gigs in size, something very strange is happening, and it would be worthwhile to investigate that. I recommend editing your question again to include a link to the Ubuntu Forums thread you're talking about, and also to include the full name of the 22 GB log file.
I'd like to add a word of caution here - maybe you can delete all your log files, but you might have problems if you delete the /var/log subdirectories. I deleted all my log files and their directories (rm -r /var/log/*) and it broke my apache2 functionality. Apparently apache doesn't/can't recreate the log directories and therefore can't write log files and that apparently can cause it to fail.
I've heard before that deleting some log files can cause problems, though I don't have any first-hand experience to support it. But of course I didn't have any first-hand experience of directory deletion being a problem until a few days ago...
Further to my original post, I found it easier to use BleachBit (on Root) to clear out all the old logs on my Ubuntu 12.10 desktop; why they get so large I still don't know, but for now BleachBit 'clears all known bits, DEAD!' I reclaimed over 1.6Gig in space. if you find similar log, problems, then check out the BleachBit utility from the Ubuntu Software Resource or Synaptic Package Manager.
I know this is old, but so is the software I'm working with lately. I needed to install an old version of Android Studio and it was running strange when launched by a standard user. So I was experimenting with running it with GKSU root. Within a couple hours of playing around my entire hard disk was gone. WTF? Well the offending files were log files in /var/log. So I launched GKSU nautilus and went looking around. It had made 3x 30gb log files which I promptly deleted since I knew what and where they came from. So while I understand the risks of running things as root, maybe this will help somebody figure out a problem.
If you are using rsync or suffering low disk space, two nice tasty targets are taken care of by these two commands:
These can get to be huge, and will be recreated the first time the system wants to write to them.
When using rsync they will not only save disk space but also will speed up the backup.