Super User is a question and answer site for computer enthusiasts and power users. 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 (still) a novice on Linux, and trying to figure out how to make mongodb start when server boots on Linux?

I'm using Amazon EC2 "default" Linux instance (no Ubuntu).

share|improve this question

You have to put a startup script into /etc/init.d or one of those rc.x.d folders (depending on the fact under which circumstances you want to start mongod).

So ideally you put a startup script into etc/init.d/ and symlink it to the appropriate rc.x.d folders. Those rc folders mean the following as of the supplied link at the bottom:

  • Runlevel 0 is when you turn your computer off.
  • Runlevel 1 is single user mode
  • Runlevel 2 is multi user mode w/o NFS
  • Runlevel 3 is multi user mode w/NFS
  • Runlevel 4 is reserved for different vendors to define
  • Runlevel 5 is GUI mode.
  • Runlevel 6 is when you reboot your computer.

The startup script itself can be as easy as:

/path/to/mongod #if you have mongod copied to some linux well known place you may only use mongod

To start a default configured mongod process, but you may want to configure it through additional parameters you can get from MongoDB - Command Line Parameters.

When you want to start mongodb only when a given user logs in you may want to add the startup script code into your .bash_profile of the corresponding user.

More can be found in this thread: Where do you place shutdown scripts?

share|improve this answer
What does the thread say? Where exactly should you put them? Please include all necessary info here. – slhck Jun 5 '12 at 8:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .