How to make a daemon for the command "mongod"

2

What is the procedure for leaving Mongo running on the server without the need to use the command mongod ?

Is there any specific Mongo command for this?

    
asked by anonymous 28.06.2016 / 19:12

2 answers

5

If you are using Linux, you can do the following:

nohub mongod &

Nohup will cause the process to continue running in the background even if you log off from the server (if you are using SSH).

There is also a possibility for you to set up a service to run this command:

See here: link

Update

According to the MongoDB Handbook , the correct way to do is by using the --fork argument when running the command.

  To run the mongod process as a daemon (i.e. fork), and write its output to a log file, use the --fork and --logpath options. You must create the log directory; however, mongod will create the log file if it does not exist.

Half-mouth translation:

  

To run a mongod process as a daemon, and write its output to a log file, use the -=-fork and --logpath options. You must create the log directory. However, mongod will create the log file if it does not exist.

To start the Mongo Daemon do:

mongod --fork --logpath /var/log/mongodb.log

To finish do:

mongod --shutdown
    
28.06.2016 / 19:19
2

Depends on whether you are running on linux or windows?

If it is in Windows only make a bat or make it turn a service and put it to start along with Windows if it is in linux ai depends on which distro you are using. I'll leave some links in the comment just for reference.

    
28.06.2016 / 19:17