MongoDB

Rotate mongodb logs without restarting mongodb

MongoDB provides varies ways to rotate log files, but most of them are configurations you have to do and restart MongoDB.

One more way provided by MongoDB to rotate the log without any configuration change or restart. It is a command and works in Linux/Unix like OS.

kill -SIGUSR1 <mongo process id>

This will rotate the current log by appending the UTC time and also creates new mongodb.log.

You will be having 2 files in /var/log/mongo, one mongo.log which is current log and another one mongo.log.2016-04-07T11-17-18