0

I have an ubuntu 22.04 LTS, I've notice that i'm running out of memory so I've analized the disk and found a file called /var/log/syslog.1 of 11,5Gb, can i delete it? I also have noticed a backups folder, can i delete them exept for the last one to save space?

1 Answers1

1

In /var/log you can delete anything ending in a digit or ending in .gz. All of those are old log files that are made because of a log rotating tool.

Mind though that removing the logs does not fix the reasons for making this log increase. Check the current log for repeating notices or errors and then find a fix for each of them.

You can do that with:

sudo -i
rm /var/log/*[0-9] /var/log/*.gz

If you want to empty the current used log use >. So with syslog as an example:

sudo -i
> /var/log/syslog

That will empty syslog but keep all permissions intact. Not sure if it is still an issue but in the past services would crash expecting a log file to be present when writing to it if that log file was there when the service was started. Using > prevents that too.

I also have noticed a backups folder, can i delete them exept for the last one to save space?

Unclear. Logrotate does not by itself use backup folders. You will need to check where it originates from. Same rules should apply though: files ending in a digit or in .gz will be older log files no longer in use.

Rinzwind
  • 299,756
  • Just deleting log files without checking / pondering on the content first might become a future problem, I suspect. – Hannu Oct 02 '22 at 09:57