Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongodb log can I empty this file without error

Can I empty the log file without spoiling the installation? I do not want to erase it. I have the installation in linux, if so, how could I do it?

like image 446
Miki Avatar asked Apr 26 '17 11:04

Miki


Video Answer


1 Answers

There are a couple of options. Probably the best way is to rotate the log file, for example via the mongo shell:

use admin
db.runCommand( { logRotate : 1 } )

You can also send a signal to the mongod process, this won't kill the process, it will just signal it to perform the rotation. Run from the linux shell:

kill -SIGUSR1 <mongod pid>

Another option to "clear" the existing log is to run (specify full path or run from the same directory as the log file):

cp /dev/null mongod.log
like image 188
helmy Avatar answered Sep 30 '22 19:09

helmy