I'm running Ubuntu 18.04 on VirtualBox. I am trying to run a shell script that launches multiple mongo instances. I want the script to run after the system reboots but before login
I have added the following line in my /etc/profile file -
/bin/sh /home/dimension/data/scripts/run_mongo_instance.sh
The shell script has the following permissions
dimension:~$ ls -lh data/scripts/run_mongo_instance.sh
-rwxrwxr-x 1 root root 313 Oct 4 17:30 data/scripts/run_mongo_instance.sh
Here are the contents of the file -
nohup mongod --config /home/dimension/data/config/archive/archive.conf &
# ReplicaSet
nohup mongod --config /home/dimension/data/config/replica/replica2.conf &
nohup mongod --config /home/dimension/data/config/replica/replica1.conf &
I am able to run this file manually by running the following command -
sudo /bin/sh /home/dimension/data/scripts/run_mongo_instance.sh
[sudo] password for dimension:
nohup: appending output to 'nohup.out'
Corresponding output -
dimension:~$ ps -ef|grep mongo
mongodb 953 1 2 10:01 ? 00:00:30 /usr/bin/mongod --quiet --config /etc/mongod.conf
root 3614 2441 1 10:03 pts/0 00:00:20 mongod --config /home/dimension/data/config/archive/archive.conf
root 3615 2441 1 10:03 pts/0 00:00:22 mongod --config /home/dimension/data/config/replica/replica2.conf
root 3616 2441 2 10:03 pts/0 00:00:27 mongod --config /home/dimension/data/config/replica/replica1.conf
dimensi+ 6145 6119 0 10:24 pts/1 00:00:00 grep --color=auto mongo
I have recently upgraded to Ubuntu 18.04. On 16.04 the command was used to run inside /etc/rc.local
How should I make this script work on 18.04?