16Gb large zypper.log

Hi!

I couldn’t log in to my computer today, as there were no space left on /. It turned out it was zypper.log in /var/log/zypper.log that was the culprit. It had grown to be over 16Gb large! I removed it, and now everything works like before…

The question is: Is there any way to prevent this log file from growing that large again, or do I have to check it regularly and delete it as root when it grows to large?

Regards,
Cast Iron

That’s pretty big! I noticed mine was about 3 gig (and there is also a zypp-refresh log that was a little over 8 gig). I went through the docs and didn’t see any way to ‘auto-purge’ the log. I just deleted them (you have to do it as root). Maybe someone else here has an idea. In the meantime, you could always cron a script to run maybe once a week that will delete the log files, which will save you from having to do it manually.

Here’s a small script to do it (sorry, it’s in Kornshell not bash):


#!/usr/bin/ksh
#
# Removes zypper and zypp-refresh.log files. Run in cron to
# do it weekly
#
typeset zypperlog=/var/log/zypper.log
typeset refreshlog=/var/log/zypp-refresh.log
typeset file
#
for file in ${zypperlog} ${refreshlog}; do
   if  -e $file ]]; then
     rm -rf $file
     if  -e $file ]]; then
       print "Error removing $file!"
       exit 1
     fi
   fi
done
#

> log files

man logrotate


DenverD (Linux Counter 282315)
A Texan in Denmark

That will do it … thanks!

logrotate seems like it would do the trick! But how do I set it up so that it removes zypper.log everytime it grows larger than, say, 1 gig? I don’t know much about setting up scripts or cron jobs so I would really appreciate an example I could just copy/paste! :slight_smile:

Thank you!

Put the script in /etc/cron.daily and it will get executed daily by cron. Or put it in cron.monthly, or weekly, etc.

Thanks! I’ll try that.

Very useful, indeed!