1

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.

  • 1
    Not sure why this got voted to close. Quite a mystery and I'm afraid I can't offer any ideas. Good luck! – shellter Sep 05 '19 at 19:33
  • 1
    I would have posted on linux.se except that I found the referenced question on SO which is almost identical and quite popular. ¯\\_(ツ)_/¯ –  Sep 05 '19 at 19:34
  • Oh, you already have `set -x` near the top of your script. If you use `set -vx` then you see the line or block of code without variables expected is show, and then you get the `set -x` view. Maybe that will illuminate something? Does the `rc.local` get `source` d? Could that be a cause (I don't see how for this case). Good luck. – shellter Sep 05 '19 at 19:39

0 Answers0