twitter-archive/kestrel

Log rotation on RHEL5 not working as expected

Closed this issue · 2 comments

I am having issues with logrotation on a centos5 server. When testing logrotation by sending a SIGHUP to the java processing running kestrel I am not seeing logs rotated.

Here is our config we are using:

loggers = new LoggerConfig {
level = Level.INFO
handlers = new FileHandlerConfig {
filename = "/var/log/kestrel/kestrel.log"
roll = Policy.SigHup
}
}

I assumed that I'd be able to move the kestrel.log to a new file, send a kill -HUP to the java process running kestrel and it would release the old filehandle and open a new one up pointing to kestrel.log but this does not seem to be the case:

[root@ kestrel]# ps auxww|grep kestrel | awk '{print $2}' | head -n 1
13773
[root@ kestrel]# lsof| grep kestrel.log
java 13773 root 32w REG 8,2 668 2366525 /var/log/kestrel/kestrel.log
[root@smo1 kestrel]# mv kestrel.log kestrel.log.1 && kill -HUP 13773
mv: overwrite `kestrel.log.1'? yes
[root@ kestrel]# lsof|grep kestrel.log
java 13773 root 32w REG 8,2 668 2366525 /var/log/kestrel/kestrel.log.1
[root@ kestrel]#

I also tested updating my configuration to do hourly rotation and have not seen any files move. here is the config we are using for hourly:

loggers = new LoggerConfig {
level = Level.INFO
handlers = new FileHandlerConfig {
filename = "/var/log/kestrel/kestrel.log"
roll = Policy.Hourly
}
}

after reloading the kestrel process i have not seen any logfiles rotate for several hours.

I am going to close this issue out. This is a pebkac error - I was backgrounding my process via "nohup" which is obviously a pretty dumb thing to do if you want to trap SIGHUP :/

I suspect once I fix my initscript things will work as expected. Sorry for the noise!

well, thanks for filing it anyway. :)