SystemD User Service Running Screen - How to Reconnect

Forum rules
Before you post please read how to get help
michaelrbanks
Level 1
Level 1
Posts: 1
Joined: Mon Aug 14, 2017 3:18 pm

SystemD User Service Running Screen - How to Reconnect

Postby michaelrbanks » Mon Aug 14, 2017 3:44 pm

I'm using Linux Mint 18.2 for a Minecraft server. Using an online tutorial, I was able to successfully create a specific minecraft user and group (different from my user name), provide directory ownership to where the server application is located, then write (below), enable and auto-start a SystemD service to start the server at system startup.

[Unit]
Description=minecraft-server

[Service]
WorkingDirectory=/home/minecraft/server
User=minecraft
Group=minecraft
Type=forking
ExecStartPre=/usr/bin/script /dev/null
ExecStart=/usr/bin/screen -h 2048 -dmS minecraft /usr/bin/java -Xms1536M -Xmx1536M -jar minecraft_server.jar nogui

[Install]
WantedBy=multi-user.target

All this works fine & people are able to log into the server through Minecraft. Now for the problem - I can't for the life of me figure out how to connect to the Screen session running under the "minecraft" user.

If I do:
myname@myserver ~ $ screen -list
No Sockets found in /var/run/screen/S-myname

If I do:
myname@myserver ~ $ sudo -u minecraft screen -list
There is a screen on:
969.minecraft (date time) (Detached)
1 Socket in /var/run/screen/S-minecraft

If I do:
myname@myserver ~ $ sudo -u minecraft screen -r
Cannot open your terminal '/dev/pts/2' - please check

I can't figure out how to reattach the Screen. I attempted adding the line "ExecStartPre=/usr/bin/script /dev/null" because I've seen several posts that this is a workaround for the issue I'm seeing. I've also tried to su to the minecraft user, but I just keep going back to the "myname@myserver ~ $ " prompt - I'm totally stuck.

Please help a noob

Return to “Scripts & Bash”