Startup-Script with SystemD and Screen wont work

General support questions
Post Reply
Chris2509
Posts: 2
Joined: 2019/08/20 08:26:55

Startup-Script with SystemD and Screen wont work

Post by Chris2509 » 2019/08/20 09:35:01

Hi, i have a CentOS7 Server with Minecraft. Everytime I start the Server, i want the Minecraft-Server starts automatically.

I read this tutorial https://notebookbft.wordpress.com/2017/ ... os-rhel-7/ and tryed it by myself, but it doesn't work and I dont know why (Im new to Linux :mrgreen: ):

Heres my Script, saved in /etc/minecraft/startup.sh
Owener/Usergroup is root, CHMOD rwxr-xr-x (0755)

Code: Select all

#!/bin/bash
screen -A -m -d -S Minecraft114 java -Xmx2048M -Xms2048M -jar /etc/minecraft/server.jar nogui

And here is my Startup-Script, saved under /etc/systemd/system/minecraft.service
Owener/Usergroup is root, CHMOD rwxr-xr-x (0755)

Code: Select all

[Unit]
Description=Minecraft Server 1.14
After=network.target

[Service]
Type=simple
ExecStart=/etc/minecraft/startup.sh
TimeoutStartSec=1

[Install]
WantedBy=default.target
Additional

Code: Select all

systemctl enable minecraft
reboot
...After restart no Screen-Session is established:

Code: Select all

[root@vir-mc1144-srv ~]# screen -ls
No Sockets found in /var/run/screen/S-root.
[root@vir-mc1144-srv ~]#
Thanks for your help!

aks
Posts: 2829
Joined: 2014/09/20 11:22:14

Re: Startup-Script with SystemD and Screen wont work

Post by aks » 2019/08/20 19:17:29

You can not use screen (which expects an attached terminal) - the terminal "getty" (that's a joke for old UNIX dues) may not be there when started. Why do you need a terminal attached (also didn't read the link and don't know about Minecraft)?

Chris2509
Posts: 2
Joined: 2019/08/20 08:26:55

Re: Startup-Script with SystemD and Screen wont work

Post by Chris2509 » 2019/08/21 10:37:24

Hi thanks for your reply. Minecraft needs a tty, which is mandatory to run the Server. If I change the Script to

Code: Select all

#!/bin/bash
java -Xmx2048M -Xms2048M -jar /etc/minecraft/server.jar nogui
It won't work either because there is no tty session :-/

aks
Posts: 2829
Joined: 2014/09/20 11:22:14

Re: Startup-Script with SystemD and Screen wont work

Post by aks » 2019/08/21 18:48:33

Not tried, but *should* work:
Use the TTY stanzas in the service file as in: https://alan-mushi.github.io/2014/10/26 ... stemd.html

Post Reply

Return to “CentOS 7 - General Support”