mongodb log can I empty this file without error

11,207

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
Share:
11,207
Miki
Author by

Miki

I worked in Cobol for years. Currently, I work for teenagers

Updated on June 08, 2022

Comments

  • Miki
    Miki almost 2 years

    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?