Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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'm currently writing process management software. One package we use is mongo.

Is there any difference between launching mongo with

mongod --fork --logpath=/my/path/mongo.log --logappend


nohup mongod >> /my/path/mongo.log 2>&1 < /dev/null &


My first thought was that --fork could spawn more processes and/or threads, and I was suggested that --fork could be useful for changing the effective user (downgrading privileges). But we run all under the same user (process manager and mongod), so is there any other difference?

Thank you

share|improve this question
Added --logappend option to make more similar. Handling logs isn't the core issue, though it gets style points. – Daniel Kitachewsky Jul 6 '12 at 17:49
up vote 4 down vote accepted

The difference is that with

mongod --fork --logpath=/my/path/mongo.log

Mongo itself forks the process so it can run as a deamon. This is the intended way because mongo might probably do something before forking the new process.


nohup mongod >> /my/path/mongo.log 2>&1 < /dev/null &

Mongo does not know it is forked.

I'd say it is always better to let server software do the forking so it can make optimizations. NoHUP is just for software that does not have a forking option.

share|improve this answer

I agree generally with Christopher P's answer (and voted it up), but to speak a little more about the logging option here. An initial scan of the examples you have given would suggest that you would end up with better logging options with the nohup version that the --fork version. If instead you started with:

mongod --fork --logpath=/my/path/mongo.log --logappend

Then, you would have a closer match. It also gives you the option of rotating the log files pretty easily (via a signal or a command):

Otherwise you would need to manage it all yourself and the process is going to think it is logging to stdout instead of to a file.

Not exactly what you were asking, but some more evidence in favor of --fork.

share|improve this answer
Logs are a separate problem indeed :) – Daniel Kitachewsky Jul 6 '12 at 17:32
I did not think of that one. Nice thinking! – Christopher Perrin Jul 6 '12 at 17:33

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.