Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is mongodb running?

People also ask

How do I know if MongoDB is running?

To verify the status of the service, type: sudo systemctl status mongodb.

How do I know if MongoDB is running Windows?

“how to check if mongodb is running windows” Code Answer'sOpen the command prompt and type "cd c:\program files\mongodb\server\your version\bin". After you enter the bin folder type "mongo start". If you get either a successful connection or failed one it means it's installed at least.

How do I run MongoDB?

To start MongoDB, run mongod.exe from the Command Prompt navigate to your MongoDB Bin folder and run mongod command, it will start MongoDB main process and The waiting for connections message in the console.


check with either:

ps -edaf | grep mongo | grep -v grep  # "ps" flags may differ on your OS

or

/etc/init.d/mongodb status     # for MongoDB version < 2.6

/etc/init.d/mongod status      # for MongoDB version >= 2.6

or

service mongodb status         # for MongoDB version < 2.6

service mongod status          # for MongoDB version >= 2.6

to see if mongod is running (you need to be root to do this, or prefix everything with sudo). Please note that the 'grep' command will always also show up as a separate process.

Check the log file /var/log/mongo/mongo.log to see if there are any problems reported.


I find:

ps -ax | grep mongo

To be a lot more consistent. The value returned can be used to detect how many instances of mongod there are running


For quickly checking if mongodb is running, this quick nc trick will let you know.

nc -zvv localhost 27017

The above command assumes that you are running it on the default port on localhost.

For auto-starting it, you might want to look at this thread.


this should work fine...

pgrep mongod


To check current running status of mongodb use: sudo service mongodb status


Correct, closing the shell will stop MongoDB. Try using the --fork command line arg for the mongod process which makes it run as a daemon instead. I'm no Unix guru, but I'm sure there must be a way to then get it to auto start when the machine boots up.

e.g.

mongod --fork --logpath /var/log/mongodb.log --logappend

Check out the full documentation on Starting and Stopping Mongo.