- Reference >
- Database Commands >
- Administration Commands >
- logRotate
logRotate¶
-
logRotate¶ The
logRotatecommand is an administrative command that allows you to rotate the MongoDB logs to prevent a single logfile from consuming too much disk space. You must issue thelogRotatecommand against the admin database in the form:Note
Your
mongodinstance needs to be running with the--logpath [file]option.You may also rotate the logs by sending a
SIGUSR1signal to themongodprocess. If yourmongodhas a process ID of 2200, here’s how to send the signal on Linux:logRotaterenames the existing log file by appending the current timestamp to the filename. The appended timestamp has the following form:Then
logRotatecreates a new log file with the same name as originally specified by thelogpathsetting tomongodormongos.