Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
03-16-2015, 03:36 PM
|
#1
|
Member
Registered: May 2006
Location: Kansas City, MO
Distribution: Various: pclos, Debian, Ubuntu, etc . . .
Posts: 649
Rep:
|
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.
|
|
|
03-16-2015, 05:15 PM
|
#2
|
Senior Member
Registered: Aug 2007
Location: Zurich, Switzerland
Distribution: Gentoo
Posts: 1,001
Rep:
|
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).
|
|
|
03-16-2015, 06:06 PM
|
#3
|
Moderator
Registered: May 2001
Posts: 29,415
|
Quote:
Originally Posted by MBA Whore
Is there a method to prevent those logs from growing so large?
|
What Pearlseattle said, really.
Quote:
Originally Posted by MBA Whore
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'.
|
|
|
03-17-2015, 04:54 PM
|
#4
|
Member
Registered: May 2006
Location: Kansas City, MO
Distribution: Various: pclos, Debian, Ubuntu, etc . . .
Posts: 649
Original Poster
Rep:
|
Quote:
Originally Posted by Pearlseattle
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!
|
|
|
03-17-2015, 04:55 PM
|
#5
|
Member
Registered: May 2006
Location: Kansas City, MO
Distribution: Various: pclos, Debian, Ubuntu, etc . . .
Posts: 649
Original Poster
Rep:
|
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?
|
|
|
03-17-2015, 06:14 PM
|
#6
|
Senior Member
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 1,019
|
Quote:
Originally Posted by MBA Whore
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...
|
|
|
03-18-2015, 03:19 AM
|
#7
|
Moderator
Registered: May 2001
Posts: 29,415
|
Quote:
Originally Posted by MBA Whore
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.
|
|
|
03-18-2015, 05:33 AM
|
#8
|
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,780
|
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)
|
|
|
03-18-2015, 09:45 AM
|
#9
|
Senior Member
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,950
|
How about gzip (or similar), followed by recreating an empty file for more logs.
This is basically what logrotate does.
|
|
|
03-18-2015, 03:07 PM
|
#10
|
Senior Member
Registered: Aug 2007
Location: Zurich, Switzerland
Distribution: Gentoo
Posts: 1,001
Rep:
|
Quote:
Originally Posted by MBA Whore
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"!
There is more than one main reason:
- 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.
- 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>.
|
|
|
03-18-2015, 05:24 PM
|
#11
|
Senior Member
Registered: Aug 2007
Location: Zurich, Switzerland
Distribution: Gentoo
Posts: 1,001
Rep:
|
Duplicate post with this one.
I don't think that it's fair to have 2 such posts running in parallel.
|
|
|
03-18-2015, 05:49 PM
|
#12
|
Senior Member
Registered: Aug 2007
Location: Zurich, Switzerland
Distribution: Gentoo
Posts: 1,001
Rep:
|
@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 06:37 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|