Puede usar logrotate para hacer este trabajo por usted.
Pon esto en /etc/logrotate.d/mongod
(asumiendo que usa Linux y tiene logrotated
instalado):
/var/log/mongo/*.log {
daily
rotate 30
compress
dateext
missingok
notifempty
sharedscripts
copytruncate
postrotate
/bin/kill -SIGUSR1 `cat /var/lib/mongo/mongod.lock 2> /dev/null` 2> /dev/null || true
endscript
}