Start mongodb and return to terminal

I can run mongodb on the terminal using the command

./mongod 

It starts the mongodb server, and then displays information to me that the server is running on this port. but it does not return my terminal. How can I run mongodb and get the terminal so that mongodb starts the background.

Just like shutting down if it starts in the background

+6
source share
2 answers

Use

 ./mongod --fork 

or

 ./mongod & 

To turn off, you must send him a TERM signal. I'm not sure if this is the same in centOS, but I do it in Ubuntu.

ps aux | grep mongod ps aux | grep mongod - find PID

kill -TERM PID - send a TERM signal.

You can also close it from the shell.

 $ ./mongo > use admin > db.shutdownServer() 
+4
source
 ./mongod & 

You will see the exit number, something similar to

 [1]+ ./mongod & 

To kill the process, execute kill %1 , where 1 is the number between the angular brackets.

+1
source

Source: https://habr.com/ru/post/905724/


All Articles