Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

can you delete any file in /var/log?

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
hthi
Posts: 213
Joined: 2015-05-09 15:43
Has thanked: 1 time

can you delete any file in /var/log?

#1 Post by hthi »

debian 8 64bit main

Because unknown errors, files in /var/log occupies all free hdd space.
Can you delete any file in /var/log without repercussions?

Can you delete in /var/log?
daemon.log
kern.log
messages
syslog
ufw.log

Thank you.

Dai_trying
Posts: 1100
Joined: 2016-01-07 12:25
Has thanked: 5 times
Been thanked: 16 times

Re: can you delete any file in /var/log?

#2 Post by Dai_trying »

You can delete these files, but you will lose the ability to tack past errors/events that have been logged, if the file does not exist the logging system usually (re)creates them. Considering you said "unknown errors" you might want to hold off from deleting them until you can track down the problem.
There are a few other ways you can free up some space for troubleshooting like clearing apt archives.

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: can you delete any file in /var/log?

#3 Post by debiman »

you should investigate the reason WHY these files are growing so much, and fix that.
idk if logrotate is active by default, but it can be used to put limits on log sizes.

User avatar
phenest
Posts: 1702
Joined: 2010-03-09 09:38
Location: The Matrix

Re: can you delete any file in /var/log?

#4 Post by phenest »

This prompted me to check my own system:

Code: Select all

su
du -hsBK /var/log/
13345756K	/var/log/
AFAIK, I have no problems, and I certainly haven't fixed anything in years. And yet I have 13GB in logs. The largest of these are messages, syslog & user.log at over 3GB each.
ASRock H77 Pro4-M i7 3770K - 32GB RAM - Pioneer BDR-209D

milomak
Posts: 2158
Joined: 2009-06-09 22:20
Been thanked: 1 time

Re: can you delete any file in /var/log?

#5 Post by milomak »

look into logrotate
Desktop: A320M-A PRO MAX, AMD Ryzen 5 3600, GALAX GeForce RTX™ 2060 Super EX (1-Click OC) - Sid, Win10, Arch Linux, Gentoo, Solus
Laptop: hp 250 G8 i3 11th Gen - Sid
Kodi: AMD Athlon 5150 APU w/Radeon HD 8400 - Sid

Bulkley
Posts: 6383
Joined: 2006-02-11 18:35
Has thanked: 2 times
Been thanked: 39 times

Re: can you delete any file in /var/log?

#6 Post by Bulkley »

As with anything you do in root, be careful. A few years back I fat-fingered a button and my computer would not boot. Nada! It took me three days to discover that I had deleted the entire /var directory. Oops :!:

ruffwoof
Posts: 298
Joined: 2016-08-20 21:00

Re: can you delete any file in /var/log?

#7 Post by ruffwoof »

phenest wrote:This prompted me to check my own system:

Code: Select all

su
du -hsBK /var/log/
13345756K	/var/log/
AFAIK, I have no problems, and I certainly haven't fixed anything in years. And yet I have 13GB in logs. The largest of these are messages, syslog & user.log at over 3GB each.
My entire Debian Jessie installation with Firefox, Kodi, Skype, Openshot, Blender .... etc. takes up 1GB of disk space. Same /var/log du command shows just over 17MB of log files. Which for me is the same every day as I reboot the exact same image every day (only /home changes).

Customised Live-Boot installed to HDD with /home persistence.

teeitup
Posts: 25
Joined: 2009-03-09 19:22

Re: can you delete any file in /var/log?

#8 Post by teeitup »

If it's a standard Debian install you should be able to move or delete files with a .gz extension.

hthi
Posts: 213
Joined: 2015-05-09 15:43
Has thanked: 1 time

Re: can you delete any file in /var/log?

#9 Post by hthi »

Thanks.
want to hold off from deleting them until you can track down the problem
investigate the reason WHY


Which I have attempted unsuccessfully. I do not know when or why the free hdd space gets occupied because files in /var/log get bigger. When it happens I do not notice until a window warns about little free space available. The warning does not display before free space available is down to about 2gb. Because the free hdd space continues to shrink, the hdd free space reaches zero before you can do anything. When you turn on the computer again, the desktop gui will not start. In stead in command line I have to rm some files in /var/log. Useful would be a function that displays a warning if free hdd space is down to about 20gb.
I will install debian 9 64bit once ready for download. Watch if the error reoccurs. If it does then it is likely an external program I install or the network.

d3viant
Posts: 24
Joined: 2017-05-17 23:36

Re: can you delete any file in /var/log?

#10 Post by d3viant »

hthi wrote:Which I have attempted unsuccessfully. I do not know when or why the free hdd space gets occupied because files in /var/log get bigger.
Are you opening the logs and reading them?

Research the error message on the web or ask here, that's what I do in attempt to get my logs smaller. :)

Use whatever viewer or editor you prefer to view these:

Code: Select all

/var/log/syslog

Code: Select all

/var/log/messages
probably fill up the quickest, so read them and research why messages are getting logged. Some messages are informational, some are errors.

(I always use pico, so I type this into my terminal to open the logs:

Code: Select all

su
[enter my root pw -- permission denied on my user account]
pico /var/log/messages
and there's a legend at the bottom explaining key shortcuts.

You can also enable logrotate:

Code: Select all

cd /etc/logrotate.d
pico rotate-all.conf
Now add this to the blank file:

Code: Select all

/var/log/* {
daily
rotate 3
size 5M
compress
delaycompress
}
It'll rotate daily, keep 3 logs, rotate once the size reaches 5M (you can make it bigger/smaller, I like to keep it semi-small as this is a fresh install, so I am trying to familiarize myself with regular info/errors.. keeping it small makes it more readable)

Now you can force it, even if the affected logs don't meet the criteria:

Code: Select all

logrotate --force rotate-all.conf
Take a peek:

Code: Select all

cd /var/log
ls
and you should see stuff like this, now:

Code: Select all

alternatives.log.1  btmp.1	     debug.1.1	 fontconfig.log.1  kern.log.2.gz  messages.2.gz      syslog.3.gz	  user.log.1.1	 Xorg.0.log.old.1
apt		    cups	     debug.2.gz  gdm3		   lastlog.1	  speech-dispatcher  ufw.log.1.1	  user.log.2.gz  Xorg.1.log.1
auth.log.1.1	    daemon.log.1.1   dpkg.log.1  installer	   lightdm	  syslog.1.1	     ufw.log.2.gz	  wtmp.1	 Xorg.1.log.old.1
auth.log.2.gz	    daemon.log.2.gz  faillog.1	 kern.log.1.1	   messages.1.1   syslog.2.gz.1      unattended-upgrades  Xorg.0.log.1	 Xorg.2.log.1
the *.1.1 and *.2.gz are the rotated logs.

If your logs are filling up at an abnormal rate, you should inspect them and see why. Driver problems / future failure predictions can be found in them.

Post Reply