With these files a minecraft server can be started in a tmux session via systemd. This allows to easily start and stop the server while still being able to connect to its console.
tmux
needs to be installed on the system.
The script was written for the following settings. If any of those don't match your system, you might have to change the script accordingly.
minecraft
exists on the system. This user will run the minecraft server./var/minecraft
/var/minecraft
)service.sh
file in the home directory of the minecraft
user.minecraft
and make sure it is executable.minecraft.service
file to /lib/systemd/system/
and reload the systemd daemon
systemctl daemon-reload
You can now start the server via systemd:
systemctl start minecraft
To attach to the tmux session that the service is running in, run:
/var/minecraft/service.sh attach