I have MongoDb running on the machine on Ubuntu 10.04.4 LTS
I there a way to find for how long was it running without restarts without accessing mongo log files
systemctl status mongod: Displays the same status of MongoDB service as like above command as shown in figure 1. pgrep mongo: Prints the process ID of running mongo instance. pgrep command looks through the list of running processes and list down the process ids based on name.
Can you check if an instance of mongod is already running? On *nix systems, you can run ps -eaf | grep mongod to find out the process id of running mongod. Also, check whether the /data/db directory is already created. If created, check the permissions whether you can write/read data.
MongoDB logs can be found in the MongoDB log files at /var/log/mongodb/mongodb. log. If you can't find the log files from this location, you can check the mongodb. conf.
For a sharded cluster, the mongos instances provide the interface between the client applications and the sharded cluster. The mongos instances route queries and write operations to the shards. From the perspective of the application, a mongos instance behaves identically to any other MongoDB instance.
In mongo shell
db.serverStatus().uptime
This will print the uptime with seconds
And you can use the following:
// minutes
db.serverStatus().uptime / 60
// hours
db.serverStatus().uptime / 3600
// days
db.serverStatus().uptime / 86400
A more convenient method:
mongo --quiet --eval "db.serverStatus().uptime"
If you can, try:
ps -ef
it works for me. You get the STIME (start time) field for all processes, including mongodb.
I get something like
my_user_id 12853 1 0 Nov13 pts/1 00:00:00 /bin/bash ./bin/start_mongodb_mongod.sh
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With