Don Diego
Don Diego

Reputation: 1488

Start mongod service at system startup

I recently updated mongodb, and I run Linux Mint (an Ubuntu based system) and every time I start it up, i cannot use Robomongo because the service mongod is not automatically started; every time I need to open up a terminal and use

sudo service mongod start

Is there a way to start mongod automatically at system start?

Upvotes: 18

Views: 24943

Answers (3)

Lelouch
Lelouch

Reputation: 579

Using crontab on Ubuntu 20 you can try this.

crontab -e

And input this as a crontab entry

@reboot service mongod start

Upvotes: 0

Yeshu Kochher
Yeshu Kochher

Reputation: 660

Use the following command to autostart mongodb when system start.

systemctl enable mongod.service

Upvotes: 53

Farhad
Farhad

Reputation: 388

You can either put the command in your /etc/bashrc script under and if condition i.e. if the mongod process is not already running, then start it.

Other way is to modify your /etc/rc.local and add the command to start mongod in that file. It will start at bootup.

Upvotes: 2

Related Questions