1

I'm fairly new to self hosting a server and Linux in general.

I'd like to autostart a modded minecraft server upon booting up the server. The minecraft server starts by executing a .sh file. After executing the script, the server continues to run in the terminal and only exits after the Minecraft server is shutdown.

I'm using Ubuntu 24.04.2 LTS without a GUI

When manually starting the server, I use screen to later access the same terminal window and being able to gracefully shutdown the Minecraft server.

The minecraft server shouldnt get started by root, but instead by an additional user (I called him "minecraft")

How would I implement this autostart? Does this work with cron or is it a problem that the script continues to run?

EDIT: I ended up creating the following service in

/etc/systemd/system/minecraftserver-dino.service

[Unit]
Description=Minecraft Server Dino Pack

[Service] Type=simple WorkingDirectory=/usr/local/games/minecraft_server/Dino ExecStart=screen -dmS Dinoserver sudo -u minecraft /usr/local/games/minecraft_server/Dino/start.sh RemainAfterExit=yes

[Install] WantedBy=multi-user.target

Now I have a working service when started manually, but when restarting the server I get an error message inside the screen which says that the script didnt find server.jar

0 Answers0