Ask MongoDB if it is Master out of a bashscript Ask MongoDB if it is Master out of a bashscript bash bash

Ask MongoDB if it is Master out of a bashscript


You can use the --eval option to mongo to do this:

MASTER=`mongo --quiet --eval "db.isMaster().ismaster"`

And then test whether MASTER == "true" in your shell script.