Bluenix
Bluenix

Reputation: 429

How to use screen in google cloud startup script?

So I decided to follow this minecraft server guide, and I'm stuck on the part linked "Automate startup and shutdown procedures". It doesn't start the server. I have tried by replacing code with a simple mkdir, which works. So I know it is being executed.

Yet I can't connect to the screen screen -list, (both when going into sudo and my own user). I checked the /run/screen/ folder and there's no other user. It means it's safe to say that it fails, and not something I set up wrong.

The code I am using is the exact copy without the mounting nor the backup.

#!/bin/bash
sudo su
cd /home/minecraft
screen -d -m -S mc java -Xms3G -Xmx7G -d64 -jar paper.jar nogui

Shouldn't this work?

EDIT: It works and I pasted the exact code I used. NOTE: I do use PaperMC, and a upgraded machine.

Upvotes: 1

Views: 2088

Answers (1)

Bruno
Bruno

Reputation: 401

I tried minecraft server guide myself and its worked properly.
At the first time, I didnt find my mcs screen with screen -list but I remembered that GCE always executes startup scripts as root after the network is available.

So my next step was simply to change my user for root with the command sudo su and from this point, my mcs screen was available with screen -list.
note that you can also use sudo screen -list

I hope that will help, if not, what is your command output when its executed on your shell?:
screen -d -m -S mc java -Xms1G -Xmx3G -d64 -jar server.jar nogui

Upvotes: 2

Related Questions