Antrikshy
Antrikshy

Reputation: 3106

Is there a Terminal command that I can use to shut down a mongod process in OS X?

mongod --shutdown is not available on OS X. The only good way seems to be using the mongo interface. Can I shut down a mongod process that was started in the background using the --fork flag using the command line? Any way to use kill with ps?

I'm trying to shut down MongoDB using an npm posttest script (just a command that's run after my unit tests).

Upvotes: 2

Views: 4209

Answers (1)

ShellFish
ShellFish

Reputation: 4551

Either find out the pid using ps | grep mongod or echo $! after starting it up (the variable $! holds the pid of the last started process) and use kill pid.

Or, simply use mongo admin --eval "db.shutdownServer()", which throws an error but seems to work anyway. You can always pipe undesired output to /dev/null.

Upvotes: 3

Related Questions