LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Prevent my logs from growing so large (https://www.linuxquestions.org/questions/linux-newbie-8/prevent-my-logs-from-growing-so-large-4175536930/)

MBA Whore 03-16-2015 03:36 PM

Prevent my logs from growing so large
 
I have a Kubuntu install that works fine but for some reason, it grows the logs into hundreds of GBs.

Is there a method to prevent those logs from growing so large? I researched "log rotate" but I couldn't understand it.

I would like something established such that after a certain size, the logs are automatically deleted so I don't have to do it manually each time.

How would I do so?

Here are the logs:

#1: /var/log/syslog
#2: /var/log/kern.log

I already determined I don't need them, so I would like to auto-delete them once they reach a certain size.

Thank you.

Pearlseattle 03-16-2015 05:15 PM

Sorry, but you definitely don't want to delete those logs by default.
If you've got those logs growing that large ("hundreds of GBs", hehe...., that's just too funny...) then you definitely want to/must look at the root cause of the problem.

I'm sure that once you fix the issue/s your PC will feed you with additional CPU/IO throuput (which will not be busy discarding the hundreds of GBs of output that you're planning to delete).

unSpawn 03-16-2015 06:06 PM

Quote:

Originally Posted by MBA Whore (Post 5333062)
Is there a method to prevent those logs from growing so large?

What Pearlseattle said, really.


Quote:

Originally Posted by MBA Whore (Post 5333062)
I researched "log rotate" but I couldn't understand it. I would like something established such that after a certain size, the logs are automatically deleted so I don't have to do it manually each time.

Then you have to "research" some more as what you describe pretty much is a default case for 'logrotate'. See contents of /etc/logrotate.d/ and examples in 'man logrotate'.

MBA Whore 03-17-2015 04:54 PM

Quote:

Originally Posted by Pearlseattle (Post 5333111)
Sorry, but you definitely don't want to delete those logs by default.
If you've got those logs growing that large ("hundreds of GBs", hehe...., that's just too funny...) then you definitely want to/must look at the root cause of the problem.

I'm sure that once you fix the issue/s your PC will feed you with additional CPU/IO throuput (which will not be busy discarding the hundreds of GBs of output that you're planning to delete).


Forgive my ignorance, but would I really need to retain those logs if this particular desktop is a dedicated "number cruncher"? What I mean is: I donate its cpu and gpu cycles to various online distributed computing projects. That is all I do with this computer.

I have a different computer for "my" needs.

With that in mind, is it ok to auto delete them by default (i.e., upon a certain size, etc?)

Thank you again for your time!

MBA Whore 03-17-2015 04:55 PM

On a related note - I can't open the logs because they are so large (the computer just freezes and runs out of ram).

Is there some way I can look into those logs to see exactly which program is causing the trouble?

joe_2000 03-17-2015 06:14 PM

Quote:

Originally Posted by MBA Whore (Post 5333668)
On a related note - I can't open the logs because they are so large (the computer just freezes and runs out of ram).

Is there some way I can look into those logs to see exactly which program is causing the trouble?

Again, logrotate is your friend. It'll break the logs into little pieces, easy to open...

unSpawn 03-18-2015 03:19 AM

Quote:

Originally Posted by MBA Whore (Post 5333668)
On a related note - I can't open the logs because they are so large (the computer just freezes and runs out of ram).
Is there some way I can look into those logs to see exactly which program is causing the trouble?

You could use 'split' (see 'man split') and then open one chunk at a time or 'head -1000 /path/to/logfile|less;' or let Logwatch generate a report as it's good in tallying errors.

pan64 03-18-2015 05:33 AM

I would suggest you to use another tool to open those files, do not use an editor (more, less, or most can be used, they will not eat up your ram)

JeremyBoden 03-18-2015 09:45 AM

How about gzip (or similar), followed by recreating an empty file for more logs.

This is basically what logrotate does.

Pearlseattle 03-18-2015 03:07 PM

Quote:

Originally Posted by MBA Whore (Post 5333667)
Forgive my ignorance, but would I really need to retain those logs if this particular desktop is a dedicated "number cruncher"? What I mean is: I donate its cpu and gpu cycles to various online distributed computing projects. That is all I do with this computer.

I have a different computer for "my" needs.

With that in mind, is it ok to auto delete them by default (i.e., upon a certain size, etc?)

Thank you again for your time!

Yes, you definitely need to keep those logs and not only that - you'll have to fix this issue and then even still check them from time to time, especially in your case where you'll use your PC as a "number cruncher for distributed computing projects"! :D

There is more than one main reason:
  1. First of all if your logs are that big (even just more than a few MBs) your PC is probably really busy by writing just those logs.
    Writing that much does not come for free and therefore the CPU&Disk&RAM resources that are used to write those logs will be for absolutely nothing - you'll be spending money on electricity for absolutely nothing instead of helping those projects.
  2. Then there is the issue that if you're doing what you're doing then your PC is permanently connected to the Internet with at least 1 open port for incoming external connections.
    As you plan to not check at all what's going on with it, your lonely PC will definitely be hijacked by some cracker who will then slave it and use it to e.g. access your other PCs/router from inside your LAN and/or join the club of buggers that try to get into my own server or do other nasty things.
There are other reasons for you to make this work even if we forget security and efficiency (e.g. you might have the same problem in the future, maybe your CPU/GPU projects are computing only hot air, maybe you'll run later into some different problem and to diagnose it you'll need to have to look at these files, etc...).


Summed up:
the files syslog and kern.log are extremely important.
If the PC writes a lot of stuff into them your PC is basically shouting "help! help!" and if you don't check & fix the problem your PC will die <gloomy music in the background>.
:)

Pearlseattle 03-18-2015 05:24 PM

Duplicate post with this one.
I don't think that it's fair to have 2 such posts running in parallel.

Pearlseattle 03-18-2015 05:49 PM

@MBA Whore
I read your other threads and I'm not thrilled.
Are you aware of the effort of the persons that write in these forums?


All times are GMT -5. The time now is 07:02 AM.