Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can I shutdown mongoDB with a command line command?
I use MacOSX but it may be similar as in linux.
If not, does someone know how I can make a script that would enter the mongo shell and shut the server down?

share|improve this question
up vote 7 down vote accepted

you can send it a termination signal per the document from any unix. you can use ps to find the PID of the mongoDB.

see the following:

Sending a Unix INT or TERM signal

You can cleanly stop mongod using a SIGINT or SIGTERM signal on Unix-like systems. Either ^C, "kill -2 PID," or kill -15 PID will work. Sending a KILL signal kill -9 will probably cause damage if mongod is not running with the --journal option. (In such a scenario, run repairDatabase command.)

After a hard crash, when not using --journal, MongoDB will say it was not shutdown cleanly, and ask you to do a repair of the database.

alternatively you can install tcl and use its expect script to send command to mongoDB shell (or any other interative program actually).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.