can you delete any file in /var/log?

New to Debian (Or Linux in general)? Ask your questions here!

can you delete any file in /var/log?

Postby hthi » 2017-05-19 15:42

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.
hthi
 
Posts: 108
Joined: 2015-05-09 15:43

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

Postby Dai_trying » 2017-05-19 16:47

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.
Dai_trying
 
Posts: 192
Joined: 2016-01-07 12:25

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

Postby debiman » 2017-05-19 17:18

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
debiman
 
Posts: 974
Joined: 2013-03-12 07:18

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

Postby phenest » 2017-05-19 18:12

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.
Dell XPS 17 L702X i7 2860QM 2.5GHz - 32GB RAM - 4G WWAN - Pioneer TD05-BDR
NEC Spirit 550 P4 3.8GHz HT - 2GB RAM - nVidia 7600GT - Pioneer BDR-209DBK
ASUS P8P67 EVO i7 3770K - 32GB RAM - 2x nVidia 660GTX SLI'd
User avatar
phenest
 
Posts: 1440
Joined: 2010-03-09 09:38
Location: The Matrix

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

Postby milomak » 2017-05-19 20:18

look into logrotate
iMac - MacOS and Windows 10 (Bootcamp)/ Debian Sid (External SSD)
Laptop (64-bit) - Debian Sid, Win10,
Kodi Box - Debian Sid
milomak
 
Posts: 1639
Joined: 2009-06-09 22:20

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

Postby Bulkley » 2017-05-19 21:50

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 :!:
Bulkley
 
Posts: 5103
Joined: 2006-02-11 18:35

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

Postby ruffwoof » 2017-05-20 00:23

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.
ruffwoof
 
Posts: 105
Joined: 2016-08-20 21:00

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

Postby teeitup » 2017-05-20 05:20

If it's a standard Debian install you should be able to move or delete files with a .gz extension.
teeitup
 
Posts: 24
Joined: 2009-03-09 19:22

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

Postby hthi » 2017-05-21 15:41

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.
hthi
 
Posts: 108
Joined: 2015-05-09 15:43

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

Postby d3viant » 2017-05-21 17:49

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.
d3viant
 
Posts: 20
Joined: 2017-05-17 23:36


Return to Beginners Questions

Who is online

Users browsing this forum: No registered users and 4 guests

fashionable