Running mongos as background process

19,052

Solution 1

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

Solution 2

To run a 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.

The following command starts mongod as a daemon and records log output to /var/log/mongodb.log.

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

Solution 3

You need to start mongos with --fork parameter. It Enables a daemon mode that runs the mongos process in the background. By default mongos does not run as a daemon: typically you will run mongos as a daemon, either by using --fork or by using a controlling process that handles the daemonization process (e.g. as with upstart and systemd).

You can also try & with the command to run it as background. for ex- mongod &

If you have ran or want to make current process to background the press Ctrl+z and type bg.

Share:
19,052
Indupriya Bhaskara
Author by

Indupriya Bhaskara

Updated on June 13, 2022

Comments

  • Indupriya Bhaskara
    Indupriya Bhaskara almost 2 years

    How can I run mongos as background process in an EC2 machine?

    I am trying to set up a sharded cluster on EC2 machines and I am able to run mongod as background service, but I am not able to run mongos as background service.

  • beNerd
    beNerd about 6 years
    and how to stop this again?
  • AATHITH RAJENDRAN
    AATHITH RAJENDRAN over 3 years
    pkill -f -9 "mongod --fork --logpath /var/log/mongod.log" this will do the job @beNerd