Mongo docs say that I can:
- use -SIGUSR1 signal and get the old log renamed and current switched
- use logrotate from OS
I want the OS's logrotate ability to zip old files and remove oldest, but see no way to tell mongod process to switch current log other than sending SIGUSR1.
So I wrote
/var/log/mongodb/*.log {
daily
rotate 5
compress
dateext
missingok
notifempty
sharedscripts
postrotate
/usr/bin/killall -SIGUSR1 mongod
/usr/bin/killall -SIGUSR1 mongos
endscript
}
to /etc/logrotate.d/mongo.
And now get well-named logfiles from logrotate and empty logfiles like mongodb.log.2013-09-18T23-49-44
as traces of SIGUSR1 switching. How to get rid of the latter?