Narf03
Posts: 243
Joined: Mon Jun 11, 2012 3:44 pm
Location: Malaysia

/var/log takes up alot of space

Thu Dec 06, 2012 8:49 am

Hi all, im not that good in debian, recently my pi run out of space and i spend hours to check where I spend them, and lastly I found the /var/log used up more than 2G of space, thats like 25% - 30% off my 8G class 10 SD card, storing things that I dont know =P

There are 2 files in that log folder which takes incredible amount of space
-rw-r----- 1 root adm 1341163765 Dec 6 16:44 auth.log
-rw-r----- 1 root adm 777934829 Dec 2 06:25 auth.log.1

These 2 files alone takes more than 2G, I need to know what these files are for and do i really need them, and can i delete them and how do i prevent pi from regenerating them, thanks.

User avatar
malakai
Posts: 1382
Joined: Sat Sep 15, 2012 10:35 am
Contact: Website

Re: /var/log takes up alot of space

Thu Dec 06, 2012 9:16 am

auth.log is pretty much as it sounds it is logging anything related to authentication as well as a few others. If your system is exposed to the outside world it is possible someone is trying to ssh in and failing a lot, could be other commands. At 2 gigs I would wonder.

First it would be a good idea to look at what is going on in it it's a text file. From there you can determine what steps to take. Google debian auth.log and linux auth.log Mostly reading the file will give you a good idea of what it does.
http://www.raspians.com - always looking for content feel free to ask to have it posted. Or sign up and message me to become a contributor to the site. Raspians is not affiliated with the Raspberry Pi Foundation. (RPi's + You = Raspians)

obcd
Posts: 917
Joined: Sun Jul 29, 2012 9:06 pm

Re: /var/log takes up alot of space

Thu Dec 06, 2012 9:30 am

As the folder name indicates, the log files are stored there.
If you have no interest in them, you can empty them. Erasing is a bad idea as some stuff expects them to exist.

sudo chmod 775 auth.log
sudo > auth.log
after this, the size of the file should be 0 bytes. You can restore it's original permissions afterwards.

you can do the same for the second file.

Narf03
Posts: 243
Joined: Mon Jun 11, 2012 3:44 pm
Location: Malaysia

Re: /var/log takes up alot of space

Thu Dec 06, 2012 9:49 am

i do program with the pi alot and i never expose it to the internet, so i think most likely its my python doing alot of "os.system('/path/file')" through ssh, i dont think ill read though a 2G file, since it has no downside empty it, then ill just empty it, thanks for all the explanations.

User avatar
jojopi
Posts: 3079
Joined: Tue Oct 11, 2011 8:38 pm

Re: /var/log takes up alot of space

Thu Dec 06, 2012 10:23 am

obcd wrote:If you have no interest in them, you can empty them.
True. But you should be interested in them. Excessively large log files could indicate a problem. Unless you take action they will surely get big again in future. And the frequent writes will slow down other I/O and produce unnecessary wear on the SD card.

The reason it is better to truncate the files than delete them is that deleting will not immediately free any space. Syslogd will carry on writing to the deleted file until the next restart.

I think you meant "true >" instead of "sudo >" after your chmod command. It is possible to truncate the file in one step, without changing the permissions, using any of these commands:

Code: Select all

sudo truncate -s0 auth.log
sudo cp /dev/null auth.log
true |sudo tee auth.log
sudo sh -c 'true > auth.log'
"true" can also be spelled ":".

Wendo
Posts: 142
Joined: Sun Jun 10, 2012 8:27 pm

Re: /var/log takes up alot of space

Thu Dec 06, 2012 6:17 pm

As a more permanent solution (since they will likely just grow again), you probably want to look at logrotate and configure it to compress or delete that log more regularly. Compressing a straight log file will drop it's size by 90%

ski522
Posts: 394
Joined: Sun Sep 30, 2012 2:22 pm

Re: /var/log takes up alot of space

Thu Dec 06, 2012 7:15 pm

Lograte is already setup by default to do this weekly, maybe you can change it to daily. In any case if you're auth files are getting that big, my guess is someone is trying to hack into your pi.

nathanwang
Posts: 1
Joined: Sun Mar 15, 2015 5:26 pm

Re: /var/log takes up alot of space

Sun Mar 15, 2015 5:28 pm

I agree. Mine takes up 27 gb. Biggest files include ./messages, ./kern.log, and ./syslog. They each take up 8.7 gig.

barsznica
Posts: 18
Joined: Thu Apr 14, 2016 12:38 pm

Re: /var/log takes up alot of space

Wed Jan 02, 2019 5:22 pm

This is how I solved my issue.

Please use that newer thread to avoid duplicates!

Return to “Troubleshooting”