Linux - NewbieThis 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.
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.
I find that after running for a few hours (Red Hat 7.3), my system
runs incredibly slow. When I do a 'top', I see that there are between
one and three instances of 'logrotate' that are using up almost all available
CPU cycles.
Basically, I'm not that interested in the logs unless there is a system problem. So how do I keep these processes from using all my CPU without letting my logs get too big? I'm primarily interested in maximizing my system's overall performance.
See if you have a /etc/logrotate.conf file.If you run Redhat there should be one.It should contain comments on how to configure it.
It may be used for a cronjob too.
lynch
If you want to disable logrotate then move logrotate out of /etc/cron.daily - if you just want to change the process priority use nice, so for instance nice 19 /usr/sbin/logrotate /etc/logrotate.conf, so you can change your /etc/cron.daily/logrotate-script to match something like:
I wouldn't recommend on disabling logrotate. Better thing is to find out *why* it keeps hogging CPU. If you find it's running again, the visual way to see what's running for newbies would be to do a "ps ax -eo pid,args --forest" (or use "top") and watch the logrotate process and any of it's children. If you find out is's a process called "run-parts" or "awk" then report the *exact* full lines back here.
PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND
7253 root 25 0 62652 60M 616 R 75.8 24.3 357:46 logrotate
2576 root 16 0 112M 20M 2300 S 21.7 8.1 217:11 X
9001 pdibona 16 0 1024 1024 800 R 1.3 0.4 0:00 top
Excellent, actually output from ps forest was enough to see it's the damn run-parts' awk script keeps hanging. Maybe we should fire off a bugzilla request at RH, I've been having this starting at say, RH 5.2? :-]
What you can do is add a simple script to your crontab, since run-parts only get used during cron activation for a whole dir like /etc/cron.daily in the case of logrotate.
Save this script somewhere cron can reach/execute it but outside the /etc/cron.* directories, because we don't want it run inadvertedly. I use a dir called /etc/cron.scripts.
#!/bin/sh
# Hand message to syslog:
awklog() { /usr/bin/logger -i -t logrotate.post "${MSG}"; }
# Lame way to make sure we only have logrotate-awk pids:
awkpid=$(/bin/ps x | grep -v grep | grep "awk -v progname=/etc/cron.daily/logrotate" | awk '{print $1}')
# Pid of logrotate
lgrpid=$(/sbin/pidof /usr/sbin/logrotate)
# If logrotate ain't running (it's finished),
# but if the remaining awk script still works,
# then kill the awk script.
if [ "$lgrpid" = "" -a "$awkpid" != "" ]; then kill -s TERM "$awkpid"; MSG="Killed awk pid $awkpid"; awklog; fi
exit 0
Now add a line in your /etc/crontab, after /etc/cron.daily get's run (w/o quotes):
"05,10,15 20 * * * root /etc/cron.scripts/logrotate.post"
This will run the script at 5, 10 and 15 minutes past 8PM and should do. Logrotate may take between 1 and 15 minutes of time depending on how much processing (for me, a lot) you add to logrotates pre/post scripts.
When run-parts > logrotate > awk get's killed run-parts will start with the next job in queue.
If you have the default "everything" installation of RedHat 7.3, odds are good that this problem is being caused by a program called mailman. With the default installation Mailman creates thousands of garbage log files in /var/log/mailman, which chokes logrotate.
Mailman is a mail usergroup program, which you probably have never used directly. If you don't use it, than the easiest way to fix your probably is to merely remove Mailman by typing:
rpm -e mailman
which will remove the rpm installation, and then:
rm -rf /var/log/mailman
which will remove the directory of mailman log files.
Once Mailman is gone, your logrotate problems will most likely vanish too.
Don't mess with the run-parts awk script. Your problem is most likely caused by the sheer number of mailman log files. run-parts isn't broken, it's actually doing its job (hence no error messages, and the high cpu usage); it's just taking a looooooooong time to do it.
You're not kidding. /var/log/mailman has over 12 Mb of logs. It took 10 minutes just to do a 'du' on that directory. I'll try your suggestion and post my results in a few days.
But in the mean time, what exactly does 'mailman' do?
While intalling sysklodg on my system, the INSTALL file had some warnings... maybe you could check..
apparentrly there are two ways of runnin logrotate.. through rc.* modules, and with the init scripts
it warns then that sometimes, if not configures correclt, and using the init method, logrotate may run more than once causin crashes
Thanks, Azureash. Your suggestion about 'mailman' was right. Now logrotate still runs, and quits in a reasonable amount of time without using all of my CPU.
Logrotate is eating away my cpu aswell. But I don't have mailman. However, looking at my /etc/logrotate.conf, I noticed something I don't know why it is there :
# RPM packages drop log rotation information into this directory
include /etc/logrotate.d
# no packages own lastlog or wtmp -- we'll rotate them here
/var/log/wtmp {
monthly
create 0664 root utmp
rotate 1
}
it is the wtmp I looked for. File size is about 35 Mb, and editing it results in a sort of encrypted text.
In logrotate.d is not that much:
-rw-r--r-- 1 root root 122 Feb 3 2000 cron
-rw-r--r-- 1 root root 78 Jun 23 2000 ftpd
-rw-r--r-- 1 root root 63 Dec 4 2000 hylafax
-rw-r--r-- 1 root root 262 Aug 27 11:29 linuxconf
-rw-r--r-- 1 root root 261 Aug 27 11:29 linuxconf~
-rw-r--r-- 1 root root 152 Nov 10 2000 named
-rw-r--r-- 1 root root 227 Feb 25 2000 samba
-rw-r--r-- 1 root root 410 Feb 3 2000 syslog
-rw-r--r-- 1 root root 544 Mar 7 2000 uucp
-rw-rw-r-- 1 root root 150 Nov 17 22:46 vhostlogs
Going through all of the files doesn't give me that much. Vhostlogs is for rotating all logs of several hundred vdomains, but I disabled them a while ago for testing purpose :
PID USER PRI NI SIZE RSS SHARE STAT LIB %CPU %MEM TIME COMMAND
8197 root 12 0 26708 26M 160 R 0 97.3 42.9 452:58 logrotate
10522 root 4 0 900 900 668 R 0 1.7 1.4 0:00 top
611 root 0 0 524 320 232 S 0 0.3 0.5 4:38 dlist
Yes, 97,3% !!! Customers complain about beeing on a slow server. Grmpffff... Is there a way to find out actual what logrotate is doing at a specific time?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.