Server Fault is a question and answer site for system and network administrators. 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

On my production stack, I have a front-end server and a Mongo server. I would like to be able to set a cron job on the front-end server to create some logs daily.

I wrote a script that does this:

./mongo server:27017/dbname --quiet my_commands.js

If I run it from the Mongo server as above, it works fine. However, I would like to be able to run it from the front-end server. When I try to do that, I get:

-bash: mongo: command not found

Since mongo is not installed on the front end server, it gives me that error.

Is it possible to somehow bind mongo to my mongo on the Mongo server?

share|improve this question
up vote 1 down vote accepted

Try providing the full path to the mongo binary, as it's likely not in the cron user's $PATH.

share|improve this answer
there is no mongo installed on the frontend server. Is there a way to point it to the mongo server? – cKendrick Nov 3 '12 at 23:40
You don't need to run the mongod process, but you do at least need the mongo client. You can use the mongo client to connect to a remote host. Full details on the client at: – gWaldo Nov 4 '12 at 17:04
do you know how I can just install the client? – cKendrick Nov 4 '12 at 19:43
I'm not sure about the CentOS yum repos, but in Ubuntu's Apt (and Canonical's repo), there is a "mongodb-clients" package. There is likely similar in the CentOS repo. – gWaldo Nov 5 '12 at 14:51
If you are using the 10gen repositories (recommended), see this page for details:… - The package "mongo-10gen" does not include the server. – gWaldo Nov 5 '12 at 14:52

Either install the Mongo client on the frontend server, or setup the cronjob on the Mongo server itself. The only other option is to make the cronjob SSH to the Mongo server and run the command, but there's no point in doing that.

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.