Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to start a mongodb using a cronjob+shell-script combo.

In the shell, mongoDB starts when I enter $ mongod, however my executable shell script fails with mongod: command not found. I then tried ./mongodb, and the error was No such file or directory.

It seems like it might be some sort of path problem (FWIW I have installed mongoDB using homebrew) but I'm not sure where to look to fix it.

How might I start a mongoDB from a shell script?

share|improve this question
Do you know the full directory path to the mongod binary? If the answer is no, the following command should work: "sudo find / -name mongod" – John in Ohio Mar 10 '13 at 6:54
+1. yes, which mongod returns a full path -- and substituting that in my script fixes the problem. make it a full answer and i'll accept it. thanks – ricardo Mar 10 '13 at 8:18
up vote 1 down vote accepted

You can determine the full directory path to the mongod binary by running the following command:

"sudo find / -name mongod"

Substitute the full path and filename of the binary instead of making a relative call to the binary as you were in the past in your script and you should see the results you're looking for.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.