Based on the question here, I have the following rc.local
#!/bin/bash
#start script
exec 2> /scriptfolder/rc.local.log
exec 1>&2
set -x
/scriptfolder/startscript.sh
exit 0
Here is the specific line of startscript.sh
that isn't working properly from rc.local
nohup sudo mongod --dbpath /scriptfolder/subfolder/ta_data/ --port 27027 --logRotate reopen --logappend --logpath /scriptfolder/autostart.mongod.log --fork &
I've also tried a few variants, including:
nohup sudo mongod --dbpath /scriptfolder/subfolder/ta_data/ --port 27027 &> /scriptfolder/autostart.mongod.log&
They all work when I run ./startscript.sh
manually but when it runs from rc.local
mongo never starts. Subsequent commands (including some docker commands) do run, so I know the script itself is executing. I don't see any errors in rc.local.log
and autostart.mongod.log
is just empty.