SystemD User Service Running Screen - How to Reconnect

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
michaelrbanks

SystemD User Service Running Screen - How to Reconnect

Post by michaelrbanks »

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
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Locked

Return to “Scripts & Bash”