I've just updated a few CentOS 5.3 servers to 5.4. One of them were a Apache Webserver. Doing a diff/check on the new ".rpmnew" config files that are made, I saw that the logrotate command for apache was changed. In 5.3 it did a reload, but in 5.4 it does a hard kill:
CentOS 5.3:
/var/log/httpd/*log { missingok notifempty sharedscripts postrotate /sbin/service httpd reload > /dev/null 2>/dev/null || true endscript }
CentOS 5.4:
/var/log/httpd/*log { missingok notifempty sharedscripts postrotate /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true endscript }
Isn't this a bit harsh in 5.4? Wouldn't the 5.3 method be better?
-Christopher Thorjussen
On Friday 15 January 2010, Christopher Thorjussen wrote:
I've just updated a few CentOS 5.3 servers to 5.4. One of them were a Apache Webserver. Doing a diff/check on the new ".rpmnew" config files that are made, I saw that the logrotate command for apache was changed. In 5.3 it did a reload, but in 5.4 it does a hard kill:
5.4 does a "kill -HUP" which is what "service httpd reload" does too. The -HUP signal causes http to re-read stuff rather than shutting down.
Still, I don't really understand why 5.4 doesn't use "service reload" which seems more "correct" (and the init.d script does a little bit of checking before the kill -HUP too).
*shrug* Peter
CentOS 5.3:
...
postrotate /sbin/service httpd reload > /dev/null 2>/dev/null || true
CentOS 5.4:
...
postrotate /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null ||
true endscript
On Fri, Jan 15, 2010 at 11:47:40AM +0100, Peter Kjellstrom wrote:
5.4 does a "kill -HUP" which is what "service httpd reload" does too. The -HUP signal causes http to re-read stuff rather than shutting down. Still, I don't really understand why 5.4 doesn't use "service reload" which seems more "correct" (and the init.d script does a little bit of checking before the kill -HUP too).
That said, *both* of them are too brutal, in that they'll kill any open connections. Signal USR1 (or service httpd graceful) is much nicer, since it lets any open connections complete. The downside is that these old connections might get written to the _rotated_ log instead of the new one, but to me that's a small price to pay.
Matthew Miller wrote:
That said, *both* of them are too brutal, in that they'll kill any open connections. Signal USR1 (or service httpd graceful) is much nicer, since it lets any open connections complete. The downside is that these old connections might get written to the _rotated_ log instead of the new one, but to me that's a small price to pay.
I've always used copytruncate for httpd logs and logrotate, never bothered to send signals to apache at all...
sample config -
"/path/to/logs/*www*log" { daily rotate 1 nocompress notifempty copytruncate missingok sharedscripts
olddir /path/to/archivedir
postrotate DATE=`date --date=Yesterday +%y%m%d` cd /path/to/archivedir for FOO in `ls *.1` do mv $FOO `echo $FOO | cut -f1 -d.`.$DATE.log done gzip -9 *.$DATE.log sleep 60 sync logger "[LOGROTATE] Rotated these logs: `echo *.${DATE}.log.gz`" endscript
}
nate
On Fri, Jan 15, 2010 at 11:35 AM, Christopher Thorjussen Christopher.Thorjussen@carrot.no wrote:
I've just updated a few CentOS 5.3 servers to 5.4. One of them were a Apache Webserver. Doing a diff/check on the new ".rpmnew" config files that are made, I saw that the logrotate command for apache was changed. In 5.3 it did a reload, but in 5.4 it does a hard kill:
CentOS 5.3:
/var/log/httpd/*log { /sbin/service httpd reload > /dev/null 2>/dev/null || true CentOS 5.4:
/var/log/httpd/*log { /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true
strange, because in my systems it does service reload logrotate-3.7.4-9
Am Freitag, den 15.01.2010, 13:08 +0100 schrieb Arturas Skauronas:
On Fri, Jan 15, 2010 at 11:35 AM, Christopher Thorjussen Christopher.Thorjussen@carrot.no wrote:
I've just updated a few CentOS 5.3 servers to 5.4. One of them were a Apache Webserver. Doing a diff/check on the new ".rpmnew" config files that are made, I saw that the logrotate command for apache was changed. In 5.3 it did a reload, but in 5.4 it does a hard kill:
CentOS 5.3:
/var/log/httpd/*log { /sbin/service httpd reload > /dev/null 2>/dev/null || true CentOS 5.4:
/var/log/httpd/*log { /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true
strange, because in my systems it does service reload logrotate-3.7.4-9
Same here.
financial.com AG
Munich head office/Hauptsitz München: Maria-Probst-Str. 19 | 80939 München | Germany Frankfurt branch office/Niederlassung Frankfurt: Messeturm | Friedrich-Ebert-Anlage 49 | 60327 Frankfurt | Germany Management board/Vorstand: Dr. Steffen Boehnert | Dr. Alexis Eisenhofer | Dr. Yann Samson | Matthias Wiederwach Supervisory board/Aufsichtsrat: Dr. Dr. Ernst zur Linden (chairman/Vorsitzender) Register court/Handelsregister: Munich – HRB 128 972 | Sales tax ID number/St.Nr.: DE205 370 553
Arturas Skauronas wrote on Fri, 15 Jan 2010 14:08:11 +0200:
strange, because in my systems it does service reload logrotate-3.7.4-9
it doesn't depend on logrotate, but on the httpd package. I think it doesn't get replaced with a newer version if you changed the file. I have only updated systems where the logrotate file had been edited and these are still there. I don't have any system installed fresh from 5.4 media yet.
Kai
On Fri, Jan 15, 2010 at 4:35 AM, Christopher Thorjussen Christopher.Thorjussen@carrot.no wrote:
I've just updated a few CentOS 5.3 servers to 5.4. One of them were a Apache Webserver. Doing a diff/check on the new ".rpmnew" config files that are made, I saw that the logrotate command for apache was changed. In 5.3 it did a reload, but in 5.4 it does a hard kill:
CentOS 5.3:
/var/log/httpd/*log { missingok notifempty sharedscripts postrotate /sbin/service httpd reload > /dev/null 2>/dev/null || true endscript }
CentOS 5.4:
/var/log/httpd/*log { missingok notifempty sharedscripts postrotate /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true endscript }
Isn't this a bit harsh in 5.4? Wouldn't the 5.3 method be better?
-Christopher Thorjussen
The "kill" command is misnamed and has undoubtedly cause this kind of confusion since its inception. What the kill command really does is send a signal to the process. By default it just happens to be the TERM signal. If you give it another signal, like HUP, it will send that one instead.
It's up to the individual program to determine what to do when receiving certain signals. In the case of HUP, many programs choose to reload their configurations. "dd" is interesting in that it prints out status information when it receives a USR1 signal.
I agree that it should be using "service" instead of kill though.