Take the 2-minute tour ×

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

2 Answers 2

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: mongodb.org/display/DOCS/mongo+-+The+Interactive+Shell –  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: docs.mongodb.org/manual/tutorial/… - 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


