Ubuntu – delete /var/log files due to low root space

deletedisk-usagelog

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.

Best Answer

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.