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




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s