Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

1 Answer

up vote 6 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.

http://www.mongodb.org/display/DOCS/Starting+and+Stopping+Mongo#StartingandStoppingMongo-Stoppingmongod

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
add comment

Your Answer

 
discard

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.