0

I need to be able to start up a screen without connecting to it, but it also needs to run my start.sh script which contains the java line to start Minecraft.

screen -d -m new3 -c start.sh

Is what I've been trying to use, but it never runs start.sh

In a snippet of code I found on line it seems to do what I want but I need some help

 mc_start() {
    cd $MCPATH
    as_user "cd $MCPATH && screen -dmS $SCREEN $INVOCATION"
    #
    # Waiting for the server to start
    #
    seconds=0
    until ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE > /dev/null
    do
        sleep 1 
        seconds=$seconds+1
        if [[ $seconds -eq 5 ]]
        then
            echo "Still not running, waiting a while longer..."
        fi
        if [[ $seconds -ge 120 ]]
        then
            echo "Failed to start, aborting."
            exit 1
        fi
    done    
    echo "$SERVICE is running."
}
Jeremy Sayers
  • 637
  • 4
  • 10
  • 23

1 Answers1

1

I think this is because your command is wrong. I'm assuming that you want to create a new session named new3 and detach from that

screen -d -m -S new3 ~/start.sh

Afterwards you can run the following command to connect back to your session.

screen -R new3
David Z.
  • 5,621
  • 2
  • 20
  • 13