12

I have an 80 GB HDD without any partitions. One day I realized that I had lost most of my free disk space. I discovered that /var/log/kern.log.1 takes up 25 GB of space, and there is no delete option for that file.

Here is a screenshot of the problem:

20130110-125652

I am new to Ubuntu/Linux. Please Help. Thank You.

xiota
  • 5,038

4 Answers4

9

You should be fine removing that file, cause it's an already rotated log. As you need root permissions to do that, you won't have an option in the GUI to delete that file.

You can do it from the command line:

sudo rm /var/log/kern.log.1

Each time you boot, log files will be created and rotated again, so you should probably watch for the next kern.log.* file sizes. Related bug report on Launchpad: https://bugs.launchpad.net/ubuntu/+source/ubuntu-meta/+bug/115774

elias
  • 1,149
7

syslog

  • To prevent excessively large log files in the future, edit /etc/logrotate.conf to limit the number and size of log files. See man logrotate for more info.

systemd

xiota
  • 5,038
1

After finding that syslog and kern.log file were increasing, I ran out of disk space. Disk space manager showed me that /var/log folder was taking a lot of space. When I ran command

tail -15 syslog  

I found repeating errors. Also syslog and kern.log file took 19 and 32 G respectively. (command for disk usage: du -h filename -h for human readability).

Deleting these files is safe, for those will recreated by the system. But if you need log record of weeks before, don't, for those aren't duplicated.

Note (Only suggestion):

1) If you are unaware of the linux file system then this is the good link: https://help.ubuntu.com/community/LinuxFilesystemTreeOverview

2) More information about log files: https://help.ubuntu.com/community/LinuxLogFiles

Going through these links will clear a lot of concepts.

K7AAY
  • 17,705
Delsilon
  • 145
1

kern.log.1 is just one of many of the kernel log files.

Together they and the messages.log.x group can take up many Gb. The rest of the log files in the directory take up about 1% of the total so there is no need to try to mass-wipe the log directory. It might even be harmful to your system..

To reclaim that 99% here are two commands that will do the trick by deleting the unnecessary multi-GB files:

sudo rm /var/log/kern* &>/dev/null
sudo rm /var/log/messages* &>/dev/null

These files will be created again the first time they are needed.

To answer your question specifically: You can set up a cron job to delete them at each midnight, or once a week, whichever.


I use them plus

rm -rf ~/.cache/chromium/Default/Cache/* &>/dev/null

for my midnight rsync backup from the primary /dev/sda SSD to the larger /dev/sdb HDD. It saves on space and they are unnecessary in any kind of restore scenario.

SDsolar
  • 3,219