0

I am unable to get mongod binary path using "db.serverStatus().process" on Ubuntu 20.04. I need to incorporate this command in a script. But "db.serverStatus().process" gives just 'mongod' as output. In Windows it gives exact path. I even included binary path in PATH environment variable and verified the path (echo $PATH).I tried using exact mongo shell path in the mongodb connect string yet same result(not simply mongo --host --port)

asked Jul 10, 2023 at 8:01
3
  • Why do you need the mongod binary path? According to documentation output mongos or mongod is the desired value, i.e. the value on Windows is actually wrong. Commented Jul 10, 2023 at 11:39
  • Hi @Wernfried Domscheit Thanks for the update. I know <systemctl status mongod> gives exact mongod binary path. But I want similar one using mongodb commands. Is there a way to achieve it. Commented Jul 11, 2023 at 12:56
  • Try db.serverCmdLineOpts().argv Commented Jul 11, 2023 at 13:09

1 Answer 1

0

Thank you so much @wernfried-domscheit. It is a good one. Output of "db.serverCmdLineOpts().argv"

db.serverCmdLineOpts().argv

[ "/mongo/4.4.22/bin/mongod", "--config", "/etc/mongod.conf" ]

I slightly modified it. Now it is giving what is required. I am just accessing [0] element from the Array which is the exact 'mongod' binary path.

Output of "db.serverCmdLineOpts().argv[0]"

db.serverCmdLineOpts().argv[0]

/mongo/4.4.22/bin/mongod
Rohit Gupta
2,1248 gold badges20 silver badges25 bronze badges
answered Jul 12, 2023 at 15:33

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.