Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
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.
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803
Rep:
Logrotate sometimes issuing error message
I'm getting emails from cron when it runs logrotate for an apache instance:
Code:
httpd: no process killed
error running postrotate script
The postrotate script is currently:
Code:
/bin/kill -HUP `pgrep -u root httpd`
The postrotate script was changed to that on the theory that there may be errors from sending SIGHUP to the Apache child processes. We just wanted to signal the parent. Before the change the script was:
Code:
/usr/bin/killall -HUP httpd
Changing the script hasn't affected the messages I'm seeing in the emails.
One other twist: despite having a 'sharedscripts' directive in the logrotate config file, I'm seeing those two error messages multiple times in my emails. This leads me to think that the postrotate script is running for every file being rotated.
When I run the 'logrotate -vf' by hand for apache, I get no errors. And no squawking about processes not being killed.
Any ideas?
I saw one discussion that mentioned that this could arise from have /tmp mounted 'noexec'. It isn't so that shouldn't be causing the messages I'm seeing.
Use "sharedscripts" in your rotate config file to control whether or not the script will run for each file versus after all files are dealt with. That shows in the logrotate man page if you wish more information.
It would seem to me that this is a permissions thing given all the other diagnosis you've performed.
Maybe also put in a fully qualified pathname for the pgrep command.
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803
Original Poster
Rep:
Quote:
Originally Posted by rtmistler
Use "sharedscripts" in your rotate config file to control whether or not the script will run for each file versus after all files are dealt with. That shows in the logrotate man page if you wish more information.
Sorry I didn't post the entire logrotate configuration. 'sharedscripts' is actually in there which is what makes some of what I'm seeing so puzzling.
Quote:
It would seem to me that this is a permissions thing given all the other diagnosis you've performed.
Not sure how permissions would come into play but I can double check. Log files are getting rotated so the permissions are not totally wrong.
Quote:
Maybe also put in a fully qualified pathname for the pgrep command.
I was entering that command from memory (not being on the actual system when I posted). Both commands have complete paths.
Someone at work mentioned in passing that this could be something 'screwy' in the 'state' file. I'm checking into that. Of course, if I find something in there, the next question will be "well what the heck caused that".
I'm also setting up a cron entry outside the normal cron.daily execution to see if I can reproduce what's happening during the cron.daily execution. As I mentioned, running logrotate 'by hand' at the command line does not generate these messages. Sometimes that's because of personal environment settings that aren't seen in the cron run but we all keep our login profiles extremely simple to avoid those situations. (I limit the changes to aliases only, keep those in a separate file, and only source that file at login if it's seen so renaming it gives me the 'default barebones' environment.) First test: run 'set' in cron to compare the results of that command issued at the command line. Could be our standard barebones profile has something in there that's thwarting my testing.
Thanks for the suggestions. I'll post what I see from my tests.
OK well as in all cases, you can add a ton more debug. You can echo stuff out to a log every time the script runs and verify if it runs "per file" or not. You can also echo out the result code of the command and a variety of other stuff, and put that all into a log file. I'd put in a ton of stuff just to ensure that what I thought was happening is really happening, and so forth.
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803
Original Poster
Rep:
Quote:
Originally Posted by rtmistler
OK well as in all cases, you can add a ton more debug. You can echo stuff out to a log every time the script runs and verify if it runs "per file" or not. You can also echo out the result code of the command and a variety of other stuff, and put that all into a log file. I'd put in a ton of stuff just to ensure that what I thought was happening is really happening, and so forth.
I've added "echo $?" statements to the postrotate script and only got a single "0" from the 'kill' command but that was during command line testing where the multiple error messages are not being produced.
Quick question:
Is there any difference between using:
Code:
sharedscript
postrotate
stuff to do
endscript
and
Code:
lastaction
stuff to do
endscript
I suspect there's a subtle difference but want to float the question and get another's opinion/experience/etc.
One thing I just noticed in the logrotate manpage: The list of the directives lists "sharedscripts" but the description refers to it as "sharedscript". I noticed that the author of the config file decided to use the plural version. It could well be that the directive is being ignored because it's spelled wrong. (Uh... shouldn't logrotate complain about that?) (Edit: 'sharedscripts is, indeed, the correct spelling despite the confusing mention of 'sharedscript' in the manpage's description. And logrotate does complain when it sees a directive that it doesn't understand.)
By the way.... I didn't see anything terribly unusual in that system's logrotate 'state' file though I admit I've never looked at one before. Names of file and rotate dates. Nothing looked weird.
Back to my testing...
Last edited by rnturn; 05-21-2015 at 02:23 PM.
Reason: Clarification
One thing I just noticed in the logrotate manpage: The list of the directives lists "sharedscripts" but the description refers to it as "sharedscript". I noticed that the author of the config file decided to use the plural version. It could well be that the directive is being ignored because it's spelled wrong. (Uh... shouldn't logrotate complain about that?) (Edit: 'sharedscripts is, indeed, the correct spelling despite the confusing mention of 'sharedscript' in the manpage's description. And logrotate does complain when it sees a directive that it doesn't understand.)
sharedscripts
Plural. I have a copy of the source and the code is performing a strcmp() against the string "sharedscripts"
The lastaction directive may be what you want if you're using a wildcard, but also realize that the man pages says "if and only if at least one log is rotated" so the action won't occur if nothing is rotated. And again, this applies when you have a wildcard qualifier to determine what log files the action is to be applied for.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.